FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: replace interface{} with any in Go/SQLite code generation by MD-Mushfiqur123 · Pull Request #4487 · sqlc-dev/sqlc · GitHub

/ sqlc Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .go  (100) .tmpl  (3) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
        • db.go
        • db.go
        • db.go
        • aggfunc.sql.go
        • db.go
        • scalarfunc.sql.go
        • db.go
        • models.go
        • query.sql.go
        • db.go
        • db.go
        • db.go
        • db.go
        • query.sql.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • query.sql.go
        • db.go
        • query.sql.go
        • db.go
        • db.go
        • db.go
        • db.go
        • query.sql.go
        • db.go
        • db.go
        • models.go
        • query.sql.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
        • db.go
2 changes: 1 addition & 1 deletion internal/codegen/golang/go_type.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ func goInnerType(req *plugin.GenerateRequest, options *opts.Options, col *plugin
case "sqlite":
return sqliteType(req, options, col)
default:
return "interface{}"
return "any"
}
}
2 changes: 1 addition & 1 deletion internal/codegen/golang/result.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func columnsToStruct(req *plugin.GenerateRequest, options *opts.Options, name st
// field with the same name has a known type, assign
// the known type to the field without a known type
for i, field := range gs.Fields {
if len(seen[field.Name]) > 1 && field.Type == "interface{}" {
if len(seen[field.Name]) > 1 && field.Type == "any" {
for _, j := range seen[field.Name] {
if i == j {
continue
Expand Down
4 changes: 2 additions & 2 deletions internal/codegen/golang/sqlite_type.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func sqliteType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.
return "json.RawMessage"

case "any":
return "interface{}"
return "any"

}

Expand Down Expand Up @@ -96,7 +96,7 @@ func sqliteType(req *plugin.GenerateRequest, options *opts.Options, col *plugin.
log.Printf("unknown SQLite type: %s\n", dt)
}

return "interface{}"
return "any"

}
}
12 changes: 6 additions & 6 deletions internal/codegen/golang/templates/stdlib/dbCode.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{define "dbCodeTemplateStd"}}
type DBTX interface {
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
ExecContext(context.Context, string, ...any) (sql.Result, error)
PrepareContext(context.Context, string) (*sql.Stmt, error)
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
QueryRowContext(context.Context, string, ...any) *sql.Row
}

{{ if .EmitMethodsWithDBArgument}}
Expand Down Expand Up @@ -42,7 +42,7 @@ func (q *Queries) Close() error {
return err
}

func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (sql.Result, error) {
func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args ...any) (sql.Result, error) {
switch {
case stmt != nil && q.tx != nil:
return q.tx.StmtContext(ctx, stmt).ExecContext(ctx, args...)
Expand All @@ -53,7 +53,7 @@ func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args .
}
}

func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Rows, error) {
func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args ...any) (*sql.Rows, error) {
switch {
case stmt != nil && q.tx != nil:
return q.tx.StmtContext(ctx, stmt).QueryContext(ctx, args...)
Expand All @@ -64,7 +64,7 @@ func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args
}
}

func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Row) {
func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...any) (*sql.Row) {
switch {
case stmt != nil && q.tx != nil:
return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...)
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (q *Queries) {{.MethodName}}(ctx context.Context, {{ dbarg }} {{.Arg.Pair}}
{{define "queryCodeStdExec"}}
{{- if .Arg.HasSqlcSlices }}
query := {{.ConstantName}}
var queryParams []interface{}
var queryParams []any
{{- if .Arg.Struct }}
{{- $arg := .Arg }}
{{- range .Arg.Struct.Fields }}
Expand Down
4 changes: 2 additions & 2 deletions internal/codegen/golang/templates/template.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const (
{{- end}}
)

func (e *{{.Name}}) Scan(src interface{}) error {
func (e *{{.Name}}) Scan(src any) error {
switch s := src.(type) {
case []byte:
*e = {{.Name}}(s)
Expand All @@ -114,7 +114,7 @@ type Null{{.Name}} struct {
}

// Scan implements the Scanner interface.
func (ns *Null{{.Name}}) Scan(value interface{}) error {
func (ns *Null{{.Name}}) Scan(value any) error {
if value == nil {
ns.{{.Name}}, ns.Valid = "", false
return nil
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/endtoend/testdata/alias/sqlite/go/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/endtoend/testdata/builtins/sqlite/go/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading

Back | FazBrowse Home | New Git URL