1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-19 02:47:04 +00:00

update dependencies

This commit is contained in:
Gerasimos (Makis) Maropoulos
2025-08-15 23:29:20 +03:00
parent de4f462198
commit a8a3afea22
186 changed files with 694 additions and 689 deletions

View File

@@ -57,7 +57,7 @@ func (db *MySQL) Drop(database string) error {
}
// Select performs the SELECT query for this database (dsn database name is required).
func (db *MySQL) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
func (db *MySQL) Select(ctx context.Context, dest any, query string, args ...any) error {
rows, err := db.Conn.QueryContext(ctx, query, args...)
if err != nil {
return err
@@ -99,7 +99,7 @@ func (db *MySQL) Select(ctx context.Context, dest interface{}, query string, arg
}
// Get same as `Select` but it moves the cursor to the first result.
func (db *MySQL) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
func (db *MySQL) Get(ctx context.Context, dest any, query string, args ...any) error {
rows, err := db.Conn.QueryContext(ctx, query, args...)
if err != nil {
return err
@@ -118,6 +118,6 @@ func (db *MySQL) Get(ctx context.Context, dest interface{}, query string, args .
// Exec executes a query. It does not return any rows.
// Use the first output parameter to count the affected rows on UPDATE, INSERT, or DELETE.
func (db *MySQL) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
func (db *MySQL) Exec(ctx context.Context, query string, args ...any) (sql.Result, error) {
return db.Conn.ExecContext(ctx, query, args...)
}

View File

@@ -38,7 +38,7 @@ func (s *Service) RecordInfo() Record {
var ErrNoRows = sql.ErrNoRows
// GetByID binds a single record from the databases to the "dest".
func (s *Service) GetByID(ctx context.Context, dest interface{}, id int64) error {
func (s *Service) GetByID(ctx context.Context, dest any, id int64) error {
q := fmt.Sprintf("SELECT * FROM %s WHERE %s = ? LIMIT 1", s.rec.TableName(), s.rec.PrimaryKey())
err := s.db.Get(ctx, dest, q, id)
return err
@@ -70,14 +70,14 @@ type ListOptions struct {
OrderByColumn string
Order string // "ASC" or "DESC" (could be a bool type instead).
WhereColumn string
WhereValue interface{}
WhereValue any
}
// Where accepts a column name and column value to set
// on the WHERE clause of the result query.
// It returns a new `ListOptions` value.
// Note that this is a basic implementation which just takes care our current needs.
func (opt ListOptions) Where(colName string, colValue interface{}) ListOptions {
func (opt ListOptions) Where(colName string, colValue any) ListOptions {
opt.WhereColumn = colName
opt.WhereValue = colValue
return opt
@@ -85,7 +85,7 @@ func (opt ListOptions) Where(colName string, colValue interface{}) ListOptions {
// BuildQuery returns the query and the arguments that
// should be form a SELECT command.
func (opt ListOptions) BuildQuery() (q string, args []interface{}) {
func (opt ListOptions) BuildQuery() (q string, args []any) {
q = fmt.Sprintf("SELECT * FROM %s", opt.Table)
if opt.WhereColumn != "" && opt.WhereValue != nil {
@@ -122,7 +122,7 @@ func ParseListOptions(q url.Values) ListOptions {
// List binds one or more records from the database to the "dest".
// If the record supports ordering then it will sort by the `Sorted.OrderBy` column name(s).
// Use the "order" input parameter to set a descending order ("DESC").
func (s *Service) List(ctx context.Context, dest interface{}, opts ListOptions) error {
func (s *Service) List(ctx context.Context, dest any, opts ListOptions) error {
// Set table and order by column from record info for `List` by options
// so it can be more flexible to perform read-only calls of other table's too.
if opts.Table == "" {
@@ -160,14 +160,14 @@ var ErrUnprocessable = errors.New("invalid entity")
// PartialUpdate accepts a columns schema and a key-value map to
// update the record based on the given "id".
// Note: Trivial string, int and boolean type validations are performed here.
func (s *Service) PartialUpdate(ctx context.Context, id int64, schema map[string]reflect.Kind, attrs map[string]interface{}) (int, error) {
func (s *Service) PartialUpdate(ctx context.Context, id int64, schema map[string]reflect.Kind, attrs map[string]any) (int, error) {
if len(schema) == 0 || len(attrs) == 0 {
return 0, nil
}
var (
keyLines []string
values []interface{}
values []any
)
for key, kind := range schema {

View File

@@ -7,9 +7,9 @@ import (
// Database is an interface which a database(sql) should implement.
type Database interface {
Get(ctx context.Context, dest interface{}, q string, args ...interface{}) error
Select(ctx context.Context, dest interface{}, q string, args ...interface{}) error
Exec(ctx context.Context, q string, args ...interface{}) (sql.Result, error)
Get(ctx context.Context, dest any, q string, args ...any) error
Select(ctx context.Context, dest any, q string, args ...any) error
Exec(ctx context.Context, q string, args ...any) (sql.Result, error)
}
// Record should represent a database record.