Skip to content

Commit

Permalink
fix: pgtype and types
Browse files Browse the repository at this point in the history
  • Loading branch information
si3nloong committed Sep 28, 2024
1 parent 95c7ce4 commit bed94b0
Show file tree
Hide file tree
Showing 25 changed files with 544 additions and 446 deletions.
16 changes: 8 additions & 8 deletions codegen/dialect/mysql/column_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func (s *mysqlDriver) ColumnDataTypes() map[string]*dialect.ColumnType {
"float32": {
DataType: s.columnDataType("FLOAT", int64(0)),
Valuer: "(float64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float32({{addrOfGoPath}})",
},
"float64": {
DataType: s.columnDataType("FLOAT", int64(0)),
Valuer: "(float64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float64({{addrOfGoPath}})",
},
"time.Time": {
DataType: s.columnDataType("TIMESTAMP", sql.RawBytes("CURRENT_TIMESTAMP")),
Expand All @@ -63,13 +63,13 @@ func (s *mysqlDriver) ColumnDataTypes() map[string]*dialect.ColumnType {
},
"*float32": {
DataType: s.columnDataType("FLOAT"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Float({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float({{addrOfGoPath}})",
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Float32({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float32({{addrOfGoPath}})",
},
"*float64": {
DataType: s.columnDataType("FLOAT"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Float({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float({{addrOfGoPath}})",
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Float64({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float64({{addrOfGoPath}})",
},
"*time.Time": {
DataType: s.columnDataType("TIMESTAMP"),
Expand Down Expand Up @@ -168,12 +168,12 @@ func (s *mysqlDriver) ColumnDataTypes() map[string]*dialect.ColumnType {
"[]float32": {
DataType: s.columnDataType("JSON"),
Valuer: "github.com/si3nloong/sqlgen/sequel/encoding.MarshalFloatList({{goPath}},-1)",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.FloatSlice({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float32Slice({{addrOfGoPath}})",
},
"[]float64": {
DataType: s.columnDataType("JSON"),
Valuer: "github.com/si3nloong/sqlgen/sequel/encoding.MarshalFloatList({{goPath}},-1)",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.FloatSlice({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float64Slice({{addrOfGoPath}})",
},
"*": {
DataType: s.columnDataType("JSON"),
Expand Down
142 changes: 83 additions & 59 deletions codegen/dialect/postgres/column_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,62 +41,62 @@ func (s *postgresDriver) ColumnDataTypes() map[string]*dialect.ColumnType {
"int8": {
DataType: s.intDataType("int2", int64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Int8({{addrOfGoPath}})",
},
"int16": {
DataType: s.intDataType("int2", int64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Int16({{addrOfGoPath}})",
},
"int32": {
DataType: s.intDataType("int4", int64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Int32({{addrOfGoPath}})",
},
"int64": {
DataType: s.columnDataType("bigint", int64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Int64({{addrOfGoPath}})",
},
"int": {
DataType: s.intDataType("int4", int64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Int({{addrOfGoPath}})",
},
"uint8": {
DataType: s.intDataType("int2", uint64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Uint8({{addrOfGoPath}})",
},
"uint16": {
DataType: s.intDataType("int2", uint64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Uint16({{addrOfGoPath}})",
},
"uint32": {
DataType: s.intDataType("int4", uint64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Uint32({{addrOfGoPath}})",
},
"uint64": {
DataType: s.intDataType("bigint", uint64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Uint64({{addrOfGoPath}})",
},
"uint": {
DataType: s.intDataType("int4", uint64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Uint({{addrOfGoPath}})",
},
"float32": {
DataType: s.columnDataType("real"),
Valuer: "(float64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float32({{addrOfGoPath}})",
},
"float64": {
DataType: s.columnDataType("double precision"),
Valuer: "(float64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float64({{addrOfGoPath}})",
},
"time.Time": {
DataType: s.columnDataType("timestamptz(6)", sql.RawBytes(`NOW()`)),
Expand All @@ -119,15 +119,65 @@ func (s *postgresDriver) ColumnDataTypes() map[string]*dialect.ColumnType {
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Bool({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Bool({{addrOfGoPath}})",
},
"*int8": {
DataType: s.intDataType("int2", int64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Int8({{addrOfGoPath}})",
},
"*int16": {
DataType: s.intDataType("int2", int64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Int16({{addrOfGoPath}})",
},
"*int32": {
DataType: s.intDataType("int4", int64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Int32({{addrOfGoPath}})",
},
"*int64": {
DataType: s.columnDataType("bigint", int64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Int64({{addrOfGoPath}})",
},
"*int": {
DataType: s.intDataType("int4", int64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
},
"*uint8": {
DataType: s.intDataType("int2", uint64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Uint8({{addrOfGoPath}})",
},
"*uint16": {
DataType: s.intDataType("int2", uint64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Uint16({{addrOfGoPath}})",
},
"*uint32": {
DataType: s.intDataType("int4", uint64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Uint32({{addrOfGoPath}})",
},
"*uint64": {
DataType: s.intDataType("bigint", uint64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Uint64({{addrOfGoPath}})",
},
"*uint": {
DataType: s.intDataType("int4", uint64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Uint({{addrOfGoPath}})",
},
"*float32": {
DataType: s.columnDataType("real"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Float({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float({{addrOfGoPath}})",
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Float32({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float32({{addrOfGoPath}})",
},
"*float64": {
DataType: s.columnDataType("double precision"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Float({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float({{addrOfGoPath}})",
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Float64({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Float64({{addrOfGoPath}})",
},
"*time.Time": {
DataType: s.columnDataType("timestamptz(6)"),
Expand Down Expand Up @@ -161,7 +211,7 @@ func (s *postgresDriver) ColumnDataTypes() map[string]*dialect.ColumnType {
"[]string": {
DataType: s.columnDataType("text[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.StringArray[{{elemType}}]({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.StringArrayScanner({{addrOfGoPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.StringArray[{{elemType}}])({{addrOfGoPath}})",
},
"[]rune": {
DataType: s.columnDataType("text"),
Expand All @@ -176,7 +226,7 @@ func (s *postgresDriver) ColumnDataTypes() map[string]*dialect.ColumnType {
"[]bool": {
DataType: s.columnDataType("bool[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.BoolArray[{{elemType}}]({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.BoolArrayScanner({{addrOfGoPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.BoolArray[{{elemType}}])({{addrOfGoPath}})",
},
"[][]byte": {
DataType: s.columnDataType("bytea"),
Expand All @@ -196,88 +246,62 @@ func (s *postgresDriver) ColumnDataTypes() map[string]*dialect.ColumnType {
"[]int": {
DataType: s.columnDataType("int4[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArrayValue({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArrayScanner({{addrOfGoPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArray[{{elemType}}])({{addrOfGoPath}})",
},
"[]int8": {
DataType: s.columnDataType("int2[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArrayValue({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArrayScanner({{addrOfGoPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArray[{{elemType}}])({{addrOfGoPath}})",
},
"[]int16": {
DataType: s.columnDataType("int2[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.Int16Array[{{elemType}}]({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArrayScanner({{addrOfGoPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArray[{{elemType}}])({{addrOfGoPath}})",
},
"[]int32": {
DataType: s.columnDataType("int4[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.Int32Array[{{elemType}}]({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArrayScanner({{addrOfGoPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArray[{{elemType}}])({{addrOfGoPath}})",
},
"[]int64": {
DataType: s.columnDataType("int8[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.Int64Array[{{elemType}}]({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArrayScanner({{addrOfGoPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.IntArray[{{elemType}}])({{addrOfGoPath}})",
},
"[]uint": {
DataType: s.columnDataType("int4[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArrayValue({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArrayScanner({{addrOfGoPath}})",
Valuer: "(github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArray[{{elemType}}])({{goPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArray[{{elemType}}])({{addrOfGoPath}})",
},
"[]uint8": {
DataType: s.columnDataType("int2[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArrayValue({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArrayScanner({{addrOfGoPath}})",
Valuer: "(github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArray[{{elemType}}])({{goPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.Uint8Array[{{elemType}}])({{addrOfGoPath}})",
},
"[]uint16": {
DataType: s.columnDataType("int2[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArrayValue({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArrayScanner({{addrOfGoPath}})",
Valuer: "(github.com/si3nloong/sqlgen/sequel/types/pgtype.Uint16Array[{{elemType}}])({{goPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.Uint16Array[{{elemType}}])({{addrOfGoPath}})",
},
"[]uint32": {
DataType: s.columnDataType("int4[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArrayValue({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArrayScanner({{addrOfGoPath}})",
Valuer: "(github.com/si3nloong/sqlgen/sequel/types/pgtype.Uint32Array[{{elemType}}])({{goPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.Uint32Array[{{elemType}}])({{addrOfGoPath}})",
},
"[]uint64": {
DataType: s.columnDataType("int8[]"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArrayValue({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types/pgtype.UintArrayScanner({{addrOfGoPath}})",
Valuer: "(github.com/si3nloong/sqlgen/sequel/types/pgtype.Uint64Array[{{elemType}}])({{goPath}})",
Scanner: "(*github.com/si3nloong/sqlgen/sequel/types/pgtype.Uint64Array[{{elemType}}])({{addrOfGoPath}})",
},
"*": {
DataType: s.columnDataType("json"),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.JSONMarshaler({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.JSONUnmarshaler({{addrOfGoPath}})",
},
}
s.mapIntegers(dataTypes)
return dataTypes
}

func (s *postgresDriver) mapIntegers(dict map[string]*dialect.ColumnType) {
types := [][2]string{
{"int", "int4"}, {"int8", "int2"}, {"int16", "int2"}, {"int32", "int4"}, {"int64", "bigint"},
{"uint", "int4"}, {"uint8", "int2"}, {"uint16", "int2"}, {"uint32", "int4"}, {"uint64", "bigint"},
}
for _, t := range types {
dict[t[0]] = &dialect.ColumnType{
DataType: s.intDataType(t[1], int64(0)),
Valuer: "(int64)({{goPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
}
}
types = [][2]string{
{"*int", "int4"}, {"*int8", "int2"}, {"*int16", "int2"}, {"*int32", "int4"}, {"*int64", "bigint"},
{"*uint", "int4"}, {"*uint8", "int2"}, {"*uint16", "int2"}, {"*uint32", "int4"}, {"*uint64", "bigint"},
}
for _, t := range types {
dict[t[0]] = &dialect.ColumnType{
DataType: s.intDataType(t[1], int64(0)),
Valuer: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
Scanner: "github.com/si3nloong/sqlgen/sequel/types.Integer({{addrOfGoPath}})",
}
}
}

func (s *postgresDriver) intDataType(dataType string, defaultValue ...any) func(dialect.GoColumn) string {
return func(column dialect.GoColumn) string {
str := dataType
Expand Down
2 changes: 1 addition & 1 deletion examples/testcase/main/generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (v HouseUnit) Values() []any {
return []any{(int64)(v.No), (time.Time)(v.BuildTime), types.JSONMarshaler(v.Address), (int64)(v.Kind), (int64)(v.Type), (int64)(v.Chan), types.JSONMarshaler(v.Inner), types.JSONMarshaler(v.Arr), encoding.MarshalFloatList(v.Slice, -1), types.JSONMarshaler(v.Map)}
}
func (v *HouseUnit) Addrs() []any {
return []any{types.Integer(&v.No), (*time.Time)(&v.BuildTime), types.JSONUnmarshaler(&v.Address), types.Integer(&v.Kind), types.Integer(&v.Type), types.Integer(&v.Chan), types.JSONUnmarshaler(&v.Inner), types.JSONUnmarshaler(&v.Arr), types.FloatSlice(&v.Slice), types.JSONUnmarshaler(&v.Map)}
return []any{types.Integer(&v.No), (*time.Time)(&v.BuildTime), types.JSONUnmarshaler(&v.Address), types.Integer(&v.Kind), types.Integer(&v.Type), types.Integer(&v.Chan), types.JSONUnmarshaler(&v.Inner), types.JSONUnmarshaler(&v.Arr), types.Float64Slice(&v.Slice), types.JSONUnmarshaler(&v.Map)}
}
func (HouseUnit) InsertPlaceholders(row int) string {
return "(?,?,?,?,?,?,?,?,?,?)"
Expand Down
2 changes: 1 addition & 1 deletion examples/testcase/main/generated.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (v HouseUnit) Values() []any {
return []any{(int64)(v.No), (time.Time)(v.BuildTime), types.JSONMarshaler(v.Address), (int64)(v.Kind), (int64)(v.Type), (int64)(v.Chan), types.JSONMarshaler(v.Inner), types.JSONMarshaler(v.Arr), encoding.MarshalFloatList(v.Slice, -1), types.JSONMarshaler(v.Map)}
}
func (v *HouseUnit) Addrs() []any {
return []any{types.Integer(&v.No), (*time.Time)(&v.BuildTime), types.JSONUnmarshaler(&v.Address), types.Integer(&v.Kind), types.Integer(&v.Type), types.Integer(&v.Chan), types.JSONUnmarshaler(&v.Inner), types.JSONUnmarshaler(&v.Arr), types.FloatSlice(&v.Slice), types.JSONUnmarshaler(&v.Map)}
return []any{types.Integer(&v.No), (*time.Time)(&v.BuildTime), types.JSONUnmarshaler(&v.Address), types.Integer(&v.Kind), types.Integer(&v.Type), types.Integer(&v.Chan), types.JSONUnmarshaler(&v.Inner), types.JSONUnmarshaler(&v.Arr), types.Float64Slice(&v.Slice), types.JSONUnmarshaler(&v.Map)}
}
func (HouseUnit) InsertPlaceholders(row int) string {
return "(?,?,?,?,?,?,?,?,?,?)"
Expand Down
2 changes: 1 addition & 1 deletion examples/testcase/struct-field/alias/generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (v AliasStruct) Values() []any {
return []any{(float64)(v.B), (int64)(v.pk.ID), (string)(v.Header), string(v.Raw), (string)(v.Text), (driver.Valuer)(v.NullStr), (time.Time)(v.model.Created), (time.Time)(v.model.Updated)}
}
func (v *AliasStruct) Addrs() []any {
return []any{types.Float(&v.B), types.Integer(&v.pk.ID), types.String(&v.Header), types.String(&v.Raw), types.String(&v.Text), (sql.Scanner)(&v.NullStr), (*time.Time)(&v.model.Created), (*time.Time)(&v.model.Updated)}
return []any{types.Float64(&v.B), types.Integer(&v.pk.ID), types.String(&v.Header), types.String(&v.Raw), types.String(&v.Text), (sql.Scanner)(&v.NullStr), (*time.Time)(&v.model.Created), (*time.Time)(&v.model.Updated)}
}
func (AliasStruct) InsertPlaceholders(row int) string {
return "(?,?,?,?,?,?,?,?)"
Expand Down
2 changes: 1 addition & 1 deletion examples/testcase/struct-field/alias/generated.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (v AliasStruct) Values() []any {
return []any{(float64)(v.B), (int64)(v.pk.ID), (string)(v.Header), string(v.Raw), (string)(v.Text), (driver.Valuer)(v.NullStr), (time.Time)(v.model.Created), (time.Time)(v.model.Updated)}
}
func (v *AliasStruct) Addrs() []any {
return []any{types.Float(&v.B), types.Integer(&v.pk.ID), types.String(&v.Header), types.String(&v.Raw), types.String(&v.Text), (sql.Scanner)(&v.NullStr), (*time.Time)(&v.model.Created), (*time.Time)(&v.model.Updated)}
return []any{types.Float64(&v.B), types.Integer(&v.pk.ID), types.String(&v.Header), types.String(&v.Raw), types.String(&v.Text), (sql.Scanner)(&v.NullStr), (*time.Time)(&v.model.Created), (*time.Time)(&v.model.Updated)}
}
func (AliasStruct) InsertPlaceholders(row int) string {
return "(?,?,?,?,?,?,?,?)"
Expand Down
Loading

0 comments on commit bed94b0

Please sign in to comment.