From 294015144bd511bb8a05706b3cc94faf083dd56f Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Wed, 7 Jan 2015 17:40:27 -0500 Subject: [PATCH 01/17] add float32 and float64 --- main.go | 2 +- meta/types.go | 2 + sqlc/field_generator.go | 2 +- sqlc/fields.go | 438 +++++++++++++++++++++++++++++++++++ sqlc/generator.go | 14 +- sqlc/schema.go | 19 +- test/generic/call_records.go | 4 +- test/migrate_db.go | 4 +- test/mysql_test.go | 4 +- test/postgres_test.go | 6 +- test/sqlite_test.go | 4 +- 11 files changed, 473 insertions(+), 26 deletions(-) diff --git a/main.go b/main.go index 22e294c..1bf96c2 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( "github.com/jessevdk/go-flags" _ "github.com/lib/pq" _ "github.com/mattn/go-sqlite3" - "github.com/relops/sqlc/sqlc" + "github.com/shutej/sqlc/sqlc" "log" "os" ) diff --git a/meta/types.go b/meta/types.go index db3eeb5..8da6345 100644 --- a/meta/types.go +++ b/meta/types.go @@ -9,6 +9,8 @@ var Types = []TypeInfo{ TypeInfo{Prefix: "String", Literal: "string"}, TypeInfo{Prefix: "Int", Literal: "int"}, TypeInfo{Prefix: "Int64", Literal: "int64"}, + TypeInfo{Prefix: "Float32", Literal: "float32"}, + TypeInfo{Prefix: "Float64", Literal: "float64"}, TypeInfo{Prefix: "Time", Literal: "time.Time"}, } diff --git a/sqlc/field_generator.go b/sqlc/field_generator.go index babe34e..4369f2f 100644 --- a/sqlc/field_generator.go +++ b/sqlc/field_generator.go @@ -6,7 +6,7 @@ import ( "bytes" "fmt" log "github.com/cihub/seelog" - "github.com/relops/sqlc/meta" + "github.com/shutej/sqlc/meta" "io/ioutil" "os" "strings" diff --git a/sqlc/fields.go b/sqlc/fields.go index 722e6e9..489429a 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -17,6 +17,10 @@ type InsertSetStep interface { SetInt64(Int64Field, int64) InsertSetMoreStep + SetFloat32(Float32Field, float32) InsertSetMoreStep + + SetFloat64(Float64Field, float64) InsertSetMoreStep + SetTime(TimeField, time.Time) InsertSetMoreStep } @@ -29,6 +33,10 @@ type UpdateSetStep interface { SetInt64(Int64Field, int64) UpdateSetMoreStep + SetFloat32(Float32Field, float32) UpdateSetMoreStep + + SetFloat64(Float64Field, float64) UpdateSetMoreStep + SetTime(TimeField, time.Time) UpdateSetMoreStep } @@ -46,6 +54,14 @@ func (i *insert) SetInt64(f Int64Field, v int64) InsertSetMoreStep { return i.set(f,v) } +func (i *insert) SetFloat32(f Float32Field, v float32) InsertSetMoreStep { + return i.set(f,v) +} + +func (i *insert) SetFloat64(f Float64Field, v float64) InsertSetMoreStep { + return i.set(f,v) +} + func (i *insert) SetTime(f TimeField, v time.Time) InsertSetMoreStep { return i.set(f,v) } @@ -64,6 +80,14 @@ func (u *update) SetInt64(f Int64Field, v int64) UpdateSetMoreStep { return u.set(f,v) } +func (u *update) SetFloat32(f Float32Field, v float32) UpdateSetMoreStep { + return u.set(f,v) +} + +func (u *update) SetFloat64(f Float64Field, v float64) UpdateSetMoreStep { + return u.set(f,v) +} + func (u *update) SetTime(f TimeField, v time.Time) UpdateSetMoreStep { return u.set(f,v) } @@ -79,6 +103,10 @@ type Reflectable interface { Int64Field(name string) Int64Field + Float32Field(name string) Float32Field + + Float64Field(name string) Float64Field + TimeField(name string) TimeField } @@ -127,6 +155,20 @@ func (t table) Int64Field(name string) Int64Field { return &int64Field{name: name, selection: t} } +func (s *selection) Float32Field(name string) Float32Field { + return &float32Field{name: name} +} +func (t table) Float32Field(name string) Float32Field { + return &float32Field{name: name, selection: t} +} + +func (s *selection) Float64Field(name string) Float64Field { + return &float64Field{name: name} +} +func (t table) Float64Field(name string) Float64Field { + return &float64Field{name: name, selection: t} +} + func (s *selection) TimeField(name string) TimeField { return &timeField{name: name} } @@ -733,6 +775,402 @@ func (c *int64Field) Hex() Field { +type float32Field struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type Float32Field interface { + TableField + + Eq(value float32) Condition + IsEq(value Float32Field) JoinCondition + + Gt(value float32) Condition + IsGt(value Float32Field) JoinCondition + + Ge(value float32) Condition + IsGe(value Float32Field) JoinCondition + + Lt(value float32) Condition + IsLt(value Float32Field) JoinCondition + + Le(value float32) Condition + IsLe(value Float32Field) JoinCondition + +} + +func (c *float32Field) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *float32Field) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &float32Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &float32Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *float32Field) As(alias string) Field { + return &float32Field{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *float32Field) Alias() string { + return c.alias +} + +func (c *float32Field) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *float32Field) Name() string { + return c.name +} + +func (c *float32Field) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *float32Field) Eq(pred float32) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *float32Field) IsEq(pred Float32Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *float32Field) Gt(pred float32) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *float32Field) IsGt(pred Float32Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *float32Field) Ge(pred float32) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *float32Field) IsGe(pred Float32Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *float32Field) Lt(pred float32) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *float32Field) IsLt(pred Float32Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *float32Field) Le(pred float32) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *float32Field) IsLe(pred Float32Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func Float32(s Selectable, name string) Float32Field { + return &float32Field{name: name, selection: s} +} + +////// + + +func (c *float32Field) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *float32Field) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *float32Field) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *float32Field) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *float32Field) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *float32Field) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *float32Field) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *float32Field) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *float32Field) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + + + + +type float64Field struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type Float64Field interface { + TableField + + Eq(value float64) Condition + IsEq(value Float64Field) JoinCondition + + Gt(value float64) Condition + IsGt(value Float64Field) JoinCondition + + Ge(value float64) Condition + IsGe(value Float64Field) JoinCondition + + Lt(value float64) Condition + IsLt(value Float64Field) JoinCondition + + Le(value float64) Condition + IsLe(value Float64Field) JoinCondition + +} + +func (c *float64Field) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *float64Field) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &float64Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &float64Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *float64Field) As(alias string) Field { + return &float64Field{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *float64Field) Alias() string { + return c.alias +} + +func (c *float64Field) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *float64Field) Name() string { + return c.name +} + +func (c *float64Field) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *float64Field) Eq(pred float64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *float64Field) IsEq(pred Float64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *float64Field) Gt(pred float64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *float64Field) IsGt(pred Float64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *float64Field) Ge(pred float64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *float64Field) IsGe(pred Float64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *float64Field) Lt(pred float64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *float64Field) IsLt(pred Float64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *float64Field) Le(pred float64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *float64Field) IsLe(pred Float64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func Float64(s Selectable, name string) Float64Field { + return &float64Field{name: name, selection: s} +} + +////// + + +func (c *float64Field) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *float64Field) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *float64Field) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *float64Field) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *float64Field) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *float64Field) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *float64Field) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *float64Field) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *float64Field) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + + + + type timeField struct { name string selection Selectable diff --git a/sqlc/generator.go b/sqlc/generator.go index 34e3d81..181e792 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -5,7 +5,7 @@ import ( "database/sql" "errors" "fmt" - "github.com/relops/sqlc/meta" + "github.com/shutej/sqlc/meta" "io/ioutil" "log" "os" @@ -17,6 +17,8 @@ import ( var integer = regexp.MustCompile("INT") var int_64 = regexp.MustCompile("INTEGER|BIGINT") +var float_32 = regexp.MustCompile("FLOAT") +var float_64 = regexp.MustCompile("DOUBLE PRECISION") var varchar = regexp.MustCompile("VARCHAR|CHARACTER VARYING|TEXT") var ts = regexp.MustCompile("TIMESTAMP|DATETIME") var dbType = regexp.MustCompile("mysql|postgres|sqlite") @@ -175,6 +177,10 @@ func infoSchema(d Dialect, schema string, db *sql.DB) ([]TableMeta, error) { fieldType = "Int64" } else if integer.MatchString(colType.String) { fieldType = "Int" + } else if float_64.MatchString(colType.String) { + fieldType = "Float64" + } else if float_32.MatchString(colType.String) { + fieldType = "Float32" } else if varchar.MatchString(colType.String) { fieldType = "String" } else if ts.MatchString(colType.String) { @@ -228,6 +234,10 @@ func sqlite(db *sql.DB) ([]TableMeta, error) { fieldType = "Int64" } else if integer.MatchString(colType.String) { fieldType = "Int" + } else if float_64.MatchString(colType.String) { + fieldType = "Float64" + } else if float_32.MatchString(colType.String) { + fieldType = "Float32" } else if varchar.MatchString(colType.String) { fieldType = "String" } else if ts.MatchString(colType.String) { @@ -260,6 +270,6 @@ const infoTablesTmpl = ` const infoColumnsTmpl = ` SELECT column_name, UPPER(data_type) - FROM information_schema.columns + FROM information_schema.columns WHERE table_schema = %s and table_name = %s; ` diff --git a/sqlc/schema.go b/sqlc/schema.go index 37f82f5..e9cb831 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -207,17 +207,14 @@ var _bindata = map[string]func() ([]byte, error){ // then AssetDir("data") would return []string{"foo.txt", "img"} // AssetDir("data/img") would return []string{"a.png", "b.png"} // AssetDir("foo.txt") and AssetDir("notexist") would return an error -// AssetDir("") will return []string{"data"}. func AssetDir(name string) ([]string, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") node := _bintree - if len(name) != 0 { - cannonicalName := strings.Replace(name, "\\", "/", -1) - pathList := strings.Split(cannonicalName, "/") - for _, p := range pathList { - node = node.Children[p] - if node == nil { - return nil, fmt.Errorf("Asset %s not found", name) - } + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) } } if node.Func != nil { @@ -237,10 +234,10 @@ type _bintree_t struct { var _bintree = &_bintree_t{nil, map[string]*_bintree_t{ "sqlc": &_bintree_t{nil, map[string]*_bintree_t{ "tmpl": &_bintree_t{nil, map[string]*_bintree_t{ - "schema.tmpl": &_bintree_t{sqlc_tmpl_schema_tmpl, map[string]*_bintree_t{ - }}, "fields.tmpl": &_bintree_t{sqlc_tmpl_fields_tmpl, map[string]*_bintree_t{ }}, + "schema.tmpl": &_bintree_t{sqlc_tmpl_schema_tmpl, map[string]*_bintree_t{ + }}, }}, }}, }} diff --git a/test/generic/call_records.go b/test/generic/call_records.go index a7fd01c..62f01be 100644 --- a/test/generic/call_records.go +++ b/test/generic/call_records.go @@ -3,8 +3,8 @@ package generic import ( "database/sql" "fmt" - "github.com/relops/sqlc/sqlc" - . "github.com/relops/sqlc/test/generated/generic" + "github.com/shutej/sqlc/sqlc" + . "github.com/shutej/sqlc/test/generated/generic" "github.com/stretchr/testify/assert" "testing" "time" diff --git a/test/migrate_db.go b/test/migrate_db.go index 17b9837..97ae958 100644 --- a/test/migrate_db.go +++ b/test/migrate_db.go @@ -8,8 +8,8 @@ import ( _ "github.com/go-sql-driver/mysql" _ "github.com/lib/pq" _ "github.com/mattn/go-sqlite3" - "github.com/relops/sqlc/sqlc" - "github.com/relops/sqlc/test" + "github.com/shutej/sqlc/sqlc" + "github.com/shutej/sqlc/test" "log" "os" ) diff --git a/test/mysql_test.go b/test/mysql_test.go index 6f8d7d9..6f0e5f7 100644 --- a/test/mysql_test.go +++ b/test/mysql_test.go @@ -3,8 +3,8 @@ package test import ( "database/sql" _ "github.com/go-sql-driver/mysql" - "github.com/relops/sqlc/sqlc" - "github.com/relops/sqlc/test/generic" + "github.com/shutej/sqlc/sqlc" + "github.com/shutej/sqlc/test/generic" "github.com/stretchr/testify/assert" "testing" ) diff --git a/test/postgres_test.go b/test/postgres_test.go index 825e8c1..e770aad 100644 --- a/test/postgres_test.go +++ b/test/postgres_test.go @@ -3,9 +3,9 @@ package test import ( "database/sql" _ "github.com/lib/pq" - "github.com/relops/sqlc/sqlc" - . "github.com/relops/sqlc/test/generated/postgres" - "github.com/relops/sqlc/test/generic" + "github.com/shutej/sqlc/sqlc" + . "github.com/shutej/sqlc/test/generated/postgres" + "github.com/shutej/sqlc/test/generic" "github.com/stretchr/testify/assert" "testing" ) diff --git a/test/sqlite_test.go b/test/sqlite_test.go index c3107bb..d9be031 100644 --- a/test/sqlite_test.go +++ b/test/sqlite_test.go @@ -3,8 +3,8 @@ package test import ( "database/sql" _ "github.com/mattn/go-sqlite3" - "github.com/relops/sqlc/sqlc" - "github.com/relops/sqlc/test/generic" + "github.com/shutej/sqlc/sqlc" + "github.com/shutej/sqlc/test/generic" "github.com/stretchr/testify/assert" "os" "testing" From 24cee36b150be619bcbd9a77b9da9de7a50c09e7 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Wed, 7 Jan 2015 18:17:20 -0500 Subject: [PATCH 02/17] updated with boolean type and the proper import in generated schemas --- meta/types.go | 1 + sqlc/fields.go | 673 +++++++++++++++++++++++------------------- sqlc/generator.go | 5 + sqlc/schema.go | 104 +++---- sqlc/tmpl/schema.tmpl | 54 ++-- 5 files changed, 462 insertions(+), 375 deletions(-) diff --git a/meta/types.go b/meta/types.go index 8da6345..4e7ff33 100644 --- a/meta/types.go +++ b/meta/types.go @@ -7,6 +7,7 @@ type TypeInfo struct { var Types = []TypeInfo{ TypeInfo{Prefix: "String", Literal: "string"}, + TypeInfo{Prefix: "Bool", Literal: "bool"}, TypeInfo{Prefix: "Int", Literal: "int"}, TypeInfo{Prefix: "Int64", Literal: "int64"}, TypeInfo{Prefix: "Float32", Literal: "float32"}, diff --git a/sqlc/fields.go b/sqlc/fields.go index 489429a..2aeb5fd 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -1,8 +1,5 @@ // THIS FILE WAS AUTOGENERATED - ANY EDITS TO THIS WILL BE LOST WHEN IT IS REGENERATED - - - package sqlc import ( @@ -10,95 +7,100 @@ import ( ) type InsertSetStep interface { - - SetString(StringField, string) InsertSetMoreStep - - SetInt(IntField, int) InsertSetMoreStep - - SetInt64(Int64Field, int64) InsertSetMoreStep - - SetFloat32(Float32Field, float32) InsertSetMoreStep - - SetFloat64(Float64Field, float64) InsertSetMoreStep - - SetTime(TimeField, time.Time) InsertSetMoreStep - + SetString(StringField, string) InsertSetMoreStep + + SetBool(BoolField, bool) InsertSetMoreStep + + SetInt(IntField, int) InsertSetMoreStep + + SetInt64(Int64Field, int64) InsertSetMoreStep + + SetFloat32(Float32Field, float32) InsertSetMoreStep + + SetFloat64(Float64Field, float64) InsertSetMoreStep + + SetTime(TimeField, time.Time) InsertSetMoreStep } type UpdateSetStep interface { - - SetString(StringField, string) UpdateSetMoreStep - - SetInt(IntField, int) UpdateSetMoreStep - - SetInt64(Int64Field, int64) UpdateSetMoreStep - - SetFloat32(Float32Field, float32) UpdateSetMoreStep - - SetFloat64(Float64Field, float64) UpdateSetMoreStep - - SetTime(TimeField, time.Time) UpdateSetMoreStep - -} + SetString(StringField, string) UpdateSetMoreStep + + SetBool(BoolField, bool) UpdateSetMoreStep + + SetInt(IntField, int) UpdateSetMoreStep + + SetInt64(Int64Field, int64) UpdateSetMoreStep + + SetFloat32(Float32Field, float32) UpdateSetMoreStep + SetFloat64(Float64Field, float64) UpdateSetMoreStep + + SetTime(TimeField, time.Time) UpdateSetMoreStep +} func (i *insert) SetString(f StringField, v string) InsertSetMoreStep { - return i.set(f,v) + return i.set(f, v) +} + +func (i *insert) SetBool(f BoolField, v bool) InsertSetMoreStep { + return i.set(f, v) } func (i *insert) SetInt(f IntField, v int) InsertSetMoreStep { - return i.set(f,v) + return i.set(f, v) } func (i *insert) SetInt64(f Int64Field, v int64) InsertSetMoreStep { - return i.set(f,v) + return i.set(f, v) } func (i *insert) SetFloat32(f Float32Field, v float32) InsertSetMoreStep { - return i.set(f,v) + return i.set(f, v) } func (i *insert) SetFloat64(f Float64Field, v float64) InsertSetMoreStep { - return i.set(f,v) + return i.set(f, v) } func (i *insert) SetTime(f TimeField, v time.Time) InsertSetMoreStep { - return i.set(f,v) + return i.set(f, v) } - - func (u *update) SetString(f StringField, v string) UpdateSetMoreStep { - return u.set(f,v) + return u.set(f, v) +} + +func (u *update) SetBool(f BoolField, v bool) UpdateSetMoreStep { + return u.set(f, v) } func (u *update) SetInt(f IntField, v int) UpdateSetMoreStep { - return u.set(f,v) + return u.set(f, v) } func (u *update) SetInt64(f Int64Field, v int64) UpdateSetMoreStep { - return u.set(f,v) + return u.set(f, v) } func (u *update) SetFloat32(f Float32Field, v float32) UpdateSetMoreStep { - return u.set(f,v) + return u.set(f, v) } func (u *update) SetFloat64(f Float64Field, v float64) UpdateSetMoreStep { - return u.set(f,v) + return u.set(f, v) } func (u *update) SetTime(f TimeField, v time.Time) UpdateSetMoreStep { - return u.set(f,v) + return u.set(f, v) } - ///// type Reflectable interface { - StringField(name string) StringField + BoolField(name string) BoolField + IntField(name string) IntField Int64Field(name string) Int64Field @@ -108,11 +110,9 @@ type Reflectable interface { Float64Field(name string) Float64Field TimeField(name string) TimeField - } type Functional interface { - Avg() Field Max() Field @@ -130,10 +130,8 @@ type Functional interface { Lower() Field Hex() Field - } - func (s *selection) StringField(name string) StringField { return &stringField{name: name} } @@ -141,6 +139,13 @@ func (t table) StringField(name string) StringField { return &stringField{name: name, selection: t} } +func (s *selection) BoolField(name string) BoolField { + return &boolField{name: name} +} +func (t table) BoolField(name string) BoolField { + return &boolField{name: name, selection: t} +} + func (s *selection) IntField(name string) IntField { return &intField{name: name} } @@ -176,36 +181,32 @@ func (t table) TimeField(name string) TimeField { return &timeField{name: name, selection: t} } - ///// - - type stringField struct { - name string + name string selection Selectable - alias string - fun FieldFunction + alias string + fun FieldFunction } type StringField interface { TableField - + Eq(value string) Condition IsEq(value StringField) JoinCondition - + Gt(value string) Condition IsGt(value StringField) JoinCondition - + Ge(value string) Condition IsGe(value StringField) JoinCondition - + Lt(value string) Condition IsLt(value StringField) JoinCondition - + Le(value string) Condition IsLe(value StringField) JoinCondition - } func (c *stringField) Function() FieldFunction { @@ -222,16 +223,16 @@ func (c *stringField) fct(fun, expr string, args ...interface{}) Field { return &stringField{ name: c.name, selection: c.selection, - fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + fun: FieldFunction{Name: fun, Expr: expr, Args: args}, } } else { return &stringField{ name: c.name, selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, Child: &FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -245,9 +246,9 @@ func (c *stringField) fct(fun, expr string, args ...interface{}) Field { func (c *stringField) As(alias string) Field { return &stringField{ - name: c.name, + name: c.name, selection: c.selection, - alias: alias, + alias: alias, fun: FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -279,8 +280,6 @@ func (c *stringField) Parent() Selectable { // -- - - func (c *stringField) Eq(pred string) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } @@ -289,8 +288,6 @@ func (c *stringField) IsEq(pred StringField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } - - func (c *stringField) Gt(pred string) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } @@ -299,8 +296,6 @@ func (c *stringField) IsGt(pred StringField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } - - func (c *stringField) Ge(pred string) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } @@ -309,8 +304,6 @@ func (c *stringField) IsGe(pred StringField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } - - func (c *stringField) Lt(pred string) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } @@ -319,8 +312,6 @@ func (c *stringField) IsLt(pred StringField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } - - func (c *stringField) Le(pred string) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } @@ -329,8 +320,6 @@ func (c *stringField) IsLe(pred StringField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } - - // -- func String(s Selectable, name string) StringField { @@ -339,71 +328,247 @@ func String(s Selectable, name string) StringField { ////// - -func (c *stringField) Avg() Field { +func (c *stringField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *stringField) Max() Field { +func (c *stringField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *stringField) Min() Field { +func (c *stringField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *stringField) Ceil() Field { +func (c *stringField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *stringField) Div(_0 interface{}) Field { +func (c *stringField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *stringField) Cast(_0 interface{}) Field { +func (c *stringField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *stringField) Md5() Field { +func (c *stringField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *stringField) Lower() Field { +func (c *stringField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *stringField) Hex() Field { +func (c *stringField) Hex() Field { return c.fct("Hex", "HEX(%s)") } +type boolField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type BoolField interface { + TableField + + Eq(value bool) Condition + IsEq(value BoolField) JoinCondition + + Gt(value bool) Condition + IsGt(value BoolField) JoinCondition + + Ge(value bool) Condition + IsGe(value BoolField) JoinCondition + + Lt(value bool) Condition + IsLt(value BoolField) JoinCondition + + Le(value bool) Condition + IsLe(value BoolField) JoinCondition +} + +func (c *boolField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *boolField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &boolField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name: fun, Expr: expr, Args: args}, + } + } else { + return &boolField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *boolField) As(alias string) Field { + return &boolField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} +func (c *boolField) Alias() string { + return c.alias +} +func (c *boolField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *boolField) Name() string { + return c.name +} + +func (c *boolField) Parent() Selectable { + return c.selection +} + +// -- + +func (c *boolField) Eq(pred bool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *boolField) IsEq(pred BoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + +func (c *boolField) Gt(pred bool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *boolField) IsGt(pred BoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + +func (c *boolField) Ge(pred bool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *boolField) IsGe(pred BoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + +func (c *boolField) Lt(pred bool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *boolField) IsLt(pred BoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + +func (c *boolField) Le(pred bool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *boolField) IsLe(pred BoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + +// -- + +func Bool(s Selectable, name string) BoolField { + return &boolField{name: name, selection: s} +} + +////// + +func (c *boolField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *boolField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *boolField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *boolField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *boolField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *boolField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *boolField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *boolField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *boolField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} type intField struct { - name string + name string selection Selectable - alias string - fun FieldFunction + alias string + fun FieldFunction } type IntField interface { TableField - + Eq(value int) Condition IsEq(value IntField) JoinCondition - + Gt(value int) Condition IsGt(value IntField) JoinCondition - + Ge(value int) Condition IsGe(value IntField) JoinCondition - + Lt(value int) Condition IsLt(value IntField) JoinCondition - + Le(value int) Condition IsLe(value IntField) JoinCondition - } func (c *intField) Function() FieldFunction { @@ -420,16 +585,16 @@ func (c *intField) fct(fun, expr string, args ...interface{}) Field { return &intField{ name: c.name, selection: c.selection, - fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + fun: FieldFunction{Name: fun, Expr: expr, Args: args}, } } else { return &intField{ name: c.name, selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, Child: &FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -443,9 +608,9 @@ func (c *intField) fct(fun, expr string, args ...interface{}) Field { func (c *intField) As(alias string) Field { return &intField{ - name: c.name, + name: c.name, selection: c.selection, - alias: alias, + alias: alias, fun: FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -477,8 +642,6 @@ func (c *intField) Parent() Selectable { // -- - - func (c *intField) Eq(pred int) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } @@ -487,8 +650,6 @@ func (c *intField) IsEq(pred IntField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } - - func (c *intField) Gt(pred int) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } @@ -497,8 +658,6 @@ func (c *intField) IsGt(pred IntField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } - - func (c *intField) Ge(pred int) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } @@ -507,8 +666,6 @@ func (c *intField) IsGe(pred IntField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } - - func (c *intField) Lt(pred int) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } @@ -517,8 +674,6 @@ func (c *intField) IsLt(pred IntField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } - - func (c *intField) Le(pred int) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } @@ -527,8 +682,6 @@ func (c *intField) IsLe(pred IntField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } - - // -- func Int(s Selectable, name string) IntField { @@ -537,71 +690,66 @@ func Int(s Selectable, name string) IntField { ////// - -func (c *intField) Avg() Field { +func (c *intField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *intField) Max() Field { +func (c *intField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *intField) Min() Field { +func (c *intField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *intField) Ceil() Field { +func (c *intField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *intField) Div(_0 interface{}) Field { +func (c *intField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *intField) Cast(_0 interface{}) Field { +func (c *intField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *intField) Md5() Field { +func (c *intField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *intField) Lower() Field { +func (c *intField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *intField) Hex() Field { +func (c *intField) Hex() Field { return c.fct("Hex", "HEX(%s)") } - - - type int64Field struct { - name string + name string selection Selectable - alias string - fun FieldFunction + alias string + fun FieldFunction } type Int64Field interface { TableField - + Eq(value int64) Condition IsEq(value Int64Field) JoinCondition - + Gt(value int64) Condition IsGt(value Int64Field) JoinCondition - + Ge(value int64) Condition IsGe(value Int64Field) JoinCondition - + Lt(value int64) Condition IsLt(value Int64Field) JoinCondition - + Le(value int64) Condition IsLe(value Int64Field) JoinCondition - } func (c *int64Field) Function() FieldFunction { @@ -618,16 +766,16 @@ func (c *int64Field) fct(fun, expr string, args ...interface{}) Field { return &int64Field{ name: c.name, selection: c.selection, - fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + fun: FieldFunction{Name: fun, Expr: expr, Args: args}, } } else { return &int64Field{ name: c.name, selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, Child: &FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -641,9 +789,9 @@ func (c *int64Field) fct(fun, expr string, args ...interface{}) Field { func (c *int64Field) As(alias string) Field { return &int64Field{ - name: c.name, + name: c.name, selection: c.selection, - alias: alias, + alias: alias, fun: FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -675,8 +823,6 @@ func (c *int64Field) Parent() Selectable { // -- - - func (c *int64Field) Eq(pred int64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } @@ -685,8 +831,6 @@ func (c *int64Field) IsEq(pred Int64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } - - func (c *int64Field) Gt(pred int64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } @@ -695,8 +839,6 @@ func (c *int64Field) IsGt(pred Int64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } - - func (c *int64Field) Ge(pred int64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } @@ -705,8 +847,6 @@ func (c *int64Field) IsGe(pred Int64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } - - func (c *int64Field) Lt(pred int64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } @@ -715,8 +855,6 @@ func (c *int64Field) IsLt(pred Int64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } - - func (c *int64Field) Le(pred int64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } @@ -725,8 +863,6 @@ func (c *int64Field) IsLe(pred Int64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } - - // -- func Int64(s Selectable, name string) Int64Field { @@ -735,71 +871,66 @@ func Int64(s Selectable, name string) Int64Field { ////// - -func (c *int64Field) Avg() Field { +func (c *int64Field) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *int64Field) Max() Field { +func (c *int64Field) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *int64Field) Min() Field { +func (c *int64Field) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *int64Field) Ceil() Field { +func (c *int64Field) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *int64Field) Div(_0 interface{}) Field { +func (c *int64Field) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *int64Field) Cast(_0 interface{}) Field { +func (c *int64Field) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *int64Field) Md5() Field { +func (c *int64Field) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *int64Field) Lower() Field { +func (c *int64Field) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *int64Field) Hex() Field { +func (c *int64Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } - - - type float32Field struct { - name string + name string selection Selectable - alias string - fun FieldFunction + alias string + fun FieldFunction } type Float32Field interface { TableField - + Eq(value float32) Condition IsEq(value Float32Field) JoinCondition - + Gt(value float32) Condition IsGt(value Float32Field) JoinCondition - + Ge(value float32) Condition IsGe(value Float32Field) JoinCondition - + Lt(value float32) Condition IsLt(value Float32Field) JoinCondition - + Le(value float32) Condition IsLe(value Float32Field) JoinCondition - } func (c *float32Field) Function() FieldFunction { @@ -816,16 +947,16 @@ func (c *float32Field) fct(fun, expr string, args ...interface{}) Field { return &float32Field{ name: c.name, selection: c.selection, - fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + fun: FieldFunction{Name: fun, Expr: expr, Args: args}, } } else { return &float32Field{ name: c.name, selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, Child: &FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -839,9 +970,9 @@ func (c *float32Field) fct(fun, expr string, args ...interface{}) Field { func (c *float32Field) As(alias string) Field { return &float32Field{ - name: c.name, + name: c.name, selection: c.selection, - alias: alias, + alias: alias, fun: FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -873,8 +1004,6 @@ func (c *float32Field) Parent() Selectable { // -- - - func (c *float32Field) Eq(pred float32) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } @@ -883,8 +1012,6 @@ func (c *float32Field) IsEq(pred Float32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } - - func (c *float32Field) Gt(pred float32) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } @@ -893,8 +1020,6 @@ func (c *float32Field) IsGt(pred Float32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } - - func (c *float32Field) Ge(pred float32) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } @@ -903,8 +1028,6 @@ func (c *float32Field) IsGe(pred Float32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } - - func (c *float32Field) Lt(pred float32) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } @@ -913,8 +1036,6 @@ func (c *float32Field) IsLt(pred Float32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } - - func (c *float32Field) Le(pred float32) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } @@ -923,8 +1044,6 @@ func (c *float32Field) IsLe(pred Float32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } - - // -- func Float32(s Selectable, name string) Float32Field { @@ -933,71 +1052,66 @@ func Float32(s Selectable, name string) Float32Field { ////// - -func (c *float32Field) Avg() Field { +func (c *float32Field) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *float32Field) Max() Field { +func (c *float32Field) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *float32Field) Min() Field { +func (c *float32Field) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *float32Field) Ceil() Field { +func (c *float32Field) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *float32Field) Div(_0 interface{}) Field { +func (c *float32Field) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *float32Field) Cast(_0 interface{}) Field { +func (c *float32Field) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *float32Field) Md5() Field { +func (c *float32Field) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *float32Field) Lower() Field { +func (c *float32Field) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *float32Field) Hex() Field { +func (c *float32Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } - - - type float64Field struct { - name string + name string selection Selectable - alias string - fun FieldFunction + alias string + fun FieldFunction } type Float64Field interface { TableField - + Eq(value float64) Condition IsEq(value Float64Field) JoinCondition - + Gt(value float64) Condition IsGt(value Float64Field) JoinCondition - + Ge(value float64) Condition IsGe(value Float64Field) JoinCondition - + Lt(value float64) Condition IsLt(value Float64Field) JoinCondition - + Le(value float64) Condition IsLe(value Float64Field) JoinCondition - } func (c *float64Field) Function() FieldFunction { @@ -1014,16 +1128,16 @@ func (c *float64Field) fct(fun, expr string, args ...interface{}) Field { return &float64Field{ name: c.name, selection: c.selection, - fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + fun: FieldFunction{Name: fun, Expr: expr, Args: args}, } } else { return &float64Field{ name: c.name, selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, Child: &FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -1037,9 +1151,9 @@ func (c *float64Field) fct(fun, expr string, args ...interface{}) Field { func (c *float64Field) As(alias string) Field { return &float64Field{ - name: c.name, + name: c.name, selection: c.selection, - alias: alias, + alias: alias, fun: FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -1071,8 +1185,6 @@ func (c *float64Field) Parent() Selectable { // -- - - func (c *float64Field) Eq(pred float64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } @@ -1081,8 +1193,6 @@ func (c *float64Field) IsEq(pred Float64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } - - func (c *float64Field) Gt(pred float64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } @@ -1091,8 +1201,6 @@ func (c *float64Field) IsGt(pred Float64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } - - func (c *float64Field) Ge(pred float64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } @@ -1101,8 +1209,6 @@ func (c *float64Field) IsGe(pred Float64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } - - func (c *float64Field) Lt(pred float64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } @@ -1111,8 +1217,6 @@ func (c *float64Field) IsLt(pred Float64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } - - func (c *float64Field) Le(pred float64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } @@ -1121,8 +1225,6 @@ func (c *float64Field) IsLe(pred Float64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } - - // -- func Float64(s Selectable, name string) Float64Field { @@ -1131,71 +1233,66 @@ func Float64(s Selectable, name string) Float64Field { ////// - -func (c *float64Field) Avg() Field { +func (c *float64Field) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *float64Field) Max() Field { +func (c *float64Field) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *float64Field) Min() Field { +func (c *float64Field) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *float64Field) Ceil() Field { +func (c *float64Field) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *float64Field) Div(_0 interface{}) Field { +func (c *float64Field) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *float64Field) Cast(_0 interface{}) Field { +func (c *float64Field) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *float64Field) Md5() Field { +func (c *float64Field) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *float64Field) Lower() Field { +func (c *float64Field) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *float64Field) Hex() Field { +func (c *float64Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } - - - type timeField struct { - name string + name string selection Selectable - alias string - fun FieldFunction + alias string + fun FieldFunction } type TimeField interface { TableField - + Eq(value time.Time) Condition IsEq(value TimeField) JoinCondition - + Gt(value time.Time) Condition IsGt(value TimeField) JoinCondition - + Ge(value time.Time) Condition IsGe(value TimeField) JoinCondition - + Lt(value time.Time) Condition IsLt(value TimeField) JoinCondition - + Le(value time.Time) Condition IsLe(value TimeField) JoinCondition - } func (c *timeField) Function() FieldFunction { @@ -1212,16 +1309,16 @@ func (c *timeField) fct(fun, expr string, args ...interface{}) Field { return &timeField{ name: c.name, selection: c.selection, - fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + fun: FieldFunction{Name: fun, Expr: expr, Args: args}, } } else { return &timeField{ name: c.name, selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, Child: &FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -1235,9 +1332,9 @@ func (c *timeField) fct(fun, expr string, args ...interface{}) Field { func (c *timeField) As(alias string) Field { return &timeField{ - name: c.name, + name: c.name, selection: c.selection, - alias: alias, + alias: alias, fun: FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -1269,8 +1366,6 @@ func (c *timeField) Parent() Selectable { // -- - - func (c *timeField) Eq(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } @@ -1279,8 +1374,6 @@ func (c *timeField) IsEq(pred TimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } - - func (c *timeField) Gt(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } @@ -1289,8 +1382,6 @@ func (c *timeField) IsGt(pred TimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } - - func (c *timeField) Ge(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } @@ -1299,8 +1390,6 @@ func (c *timeField) IsGe(pred TimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } - - func (c *timeField) Lt(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } @@ -1309,8 +1398,6 @@ func (c *timeField) IsLt(pred TimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } - - func (c *timeField) Le(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } @@ -1319,8 +1406,6 @@ func (c *timeField) IsLe(pred TimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } - - // -- func Time(s Selectable, name string) TimeField { @@ -1329,42 +1414,38 @@ func Time(s Selectable, name string) TimeField { ////// - -func (c *timeField) Avg() Field { +func (c *timeField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *timeField) Max() Field { +func (c *timeField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *timeField) Min() Field { +func (c *timeField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *timeField) Ceil() Field { +func (c *timeField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *timeField) Div(_0 interface{}) Field { +func (c *timeField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *timeField) Cast(_0 interface{}) Field { +func (c *timeField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *timeField) Md5() Field { +func (c *timeField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *timeField) Lower() Field { +func (c *timeField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *timeField) Hex() Field { +func (c *timeField) Hex() Field { return c.fct("Hex", "HEX(%s)") } - - - diff --git a/sqlc/generator.go b/sqlc/generator.go index 181e792..3bd6a0a 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -15,6 +15,7 @@ import ( "time" ) +var boolean = regexp.MustCompile("BOOLEAN") var integer = regexp.MustCompile("INT") var int_64 = regexp.MustCompile("INTEGER|BIGINT") var float_32 = regexp.MustCompile("FLOAT") @@ -185,6 +186,8 @@ func infoSchema(d Dialect, schema string, db *sql.DB) ([]TableMeta, error) { fieldType = "String" } else if ts.MatchString(colType.String) { fieldType = "Time" + } else if boolean.MatchString(colType.String) { + fieldType = "Bool" } field := FieldMeta{Name: colName.String, Type: fieldType} @@ -242,6 +245,8 @@ func sqlite(db *sql.DB) ([]TableMeta, error) { fieldType = "String" } else if ts.MatchString(colType.String) { fieldType = "Time" + } else if boolean.MatchString(colType.String) { + fieldType = "Bool" } field := FieldMeta{Name: colName.String, Type: fieldType} diff --git a/sqlc/schema.go b/sqlc/schema.go index e9cb831..380268f 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -118,53 +118,53 @@ func sqlc_tmpl_fields_tmpl() ([]byte, error) { func sqlc_tmpl_schema_tmpl() ([]byte, error) { return bindata_read([]byte{ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0x9c, 0x54, - 0x61, 0x6f, 0xda, 0x30, 0x10, 0xfd, 0x4c, 0x7e, 0xc5, 0x29, 0xaa, 0xa6, - 0x64, 0xea, 0xc2, 0x77, 0x24, 0x3e, 0x64, 0x6a, 0xda, 0x46, 0x62, 0x61, - 0x22, 0xa6, 0x68, 0x9a, 0x26, 0x64, 0x52, 0x87, 0x45, 0x0b, 0x49, 0x66, - 0x9b, 0x6e, 0x08, 0xf1, 0xdf, 0x77, 0xb6, 0x49, 0x49, 0xc1, 0x14, 0x34, - 0x84, 0x90, 0x39, 0xbf, 0x7b, 0xf7, 0xee, 0xf9, 0xec,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80, 0x62, 0x1d, 0x57, 0x52, + 0x63, 0x0c, 0xce, 0x9c, 0x7b, 0xee, 0x39, 0x67, 0xee, 0x30, 0x1c, 0x02, + 0x79, 0x0a, 0x63, 0x78, 0x08, 0x27, 0x01, 0x2c, 0xfc, 0x18, 0xfc, 0x39, + 0x99, 0x3e, 0x06, 0x51, 0x30, 0xf3, 0x49, 0x70, 0x0f, 0x1f, 0xc0, 0x8f, + 0xbe, 0x40, 0x70, 0x1f, 0x92, 0x18, 0xc8, 0x54, 0x43, 0x17, 0xe1, 0x64, + 0x02, 0x1f, 0x03, 0x98, 0x4c, 0x63, 0x02, 0x8b, 0xa7, 0x20, 0x82, 0x90, + 0x00, 0xae, 0xcf, 0x82, 0x63, 0x9d, 0x85, 0xb4, 0x3e, 0x81, 0xfd, 0x1e, + 0xbc, 0xcf, 0x75, 0xf9, 0xc6, 0x0a, 0x5a, 0x24, 0xcc, 0x23, 0xd9, 0x86, + 0x71, 0x41, 0x37, 0x15, 0x1c, 0x0e, 0x30, 0x8f, 0xc3, 0xe8, 0x11, 0xf8, + 0xcf, 0x3c, 0x81, 0xe7, 0x60, 0x16, 0x87, 0xd3, 0xe8, 0x6f, 0xf8, 0x33, + 0xab, 0x79, 0x56, 0x16, 0x08, 0xb6, 0x2c, 0xdc, 0xba, 0x13, 0xbb, 0x8a, + 0x71, 0x18, 0x8d, 0xc1, 0x23, 0xea, 0x49, 0xae, 0x57, 0x34, 0xf9, 0x41, + 0xd7, 0x4c, 0x97, 0x36, 0xcf, 0x72, 0x3d, 0xdb, 0x54, 0x65, 0x2d, 0xc0, + 0xb1, 0x00, 0xec, 0x75, 0x26, 0x5e, 0xb7, 0x2b, 0x2f, 0x29, 0x37, 0x43, + 0xfe, 0xba, 0x15, 0xec, 0xfb, 0x50, 0x76, 0x55, 0x3f, 0xb6, 0xdc, 0xe7, + 0xa2, 0xce, 0x8a, 0x35, 0xb7, 0x2d, 0x57, 0xf5, 0xa9, 0x69, 0x81, 0x24, + 0x77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0xe5, 0x9c, 0x9d, 0xa3, 0x5b, 0x39, 0x8d, 0xaf, 0xa1, + 0xfc, 0x5c, 0x8c, 0xfc, 0x4e, 0xa7, 0xda, 0xde, 0xb0, 0x5b, 0xba, 0xf5, + 0xc5, 0xc4, 0x6b, 0xcb, 0xd2, 0xec, 0x77, 0x3b, 0xb1, 0x4e, 0x21, 0xb7, + 0xcf, 0x0e, 0xdb, 0x88, 0xeb, 0x66, 0x65, 0x44, 0x39, 0xdd, 0x43, 0x3b, + 0x76, 0x1d, 0x34, 0xd4, 0xdc, 0x23, 0x7a, 0x4f, 0xf5, 0x73, 0x5d, 0x34, + 0x75, 0x3a, 0xc9, 0xd6, 0xde, 0x2d, 0x03, 0x7a, 0x7a, 0x30, 0xf4, 0xaf, + 0xdf, 0x94, 0x84, 0x0b, 0x61, 0xdd, 0xf5, 0xfe, 0x63, 0x78, 0x79, 0x97, + 0xaf, 0x79, 0xb1, 0x8d, 0x83, 0x69, 0xbb, 0x97, 0xa3, 0xa9, 0x4e, 0xad, + 0xe3, 0xf0, 0xfd, 0x97, 0xd5, 0x1b, 0xad, 0x61, 0xb9, 0x34, 0xbf, 0xac, + 0xc6, 0xd7, 0xae, 0x99, 0x2e, 0x33, 0x2a, 0xbd, 0x5a, 0x84, 0x61, 0x59, + 0xff, 0xf8, 0xca, 0x1b, 0x99, 0x72, 0xba, 0x22, 0xfa, 0xbd, 0xa4, 0x3a, + 0xa1, 0xe0, 0xf7, 0xf4, 0xf7, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfa, + 0xae, 0x6b, 0xb0, 0xde, 0x06, 0x00, 0x00, }, "sqlc/tmpl/schema.tmpl", ) @@ -195,6 +195,7 @@ var _bindata = map[string]func() ([]byte, error){ "sqlc/tmpl/fields.tmpl": sqlc_tmpl_fields_tmpl, "sqlc/tmpl/schema.tmpl": sqlc_tmpl_schema_tmpl, } + // AssetDir returns the file names below a certain // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the @@ -228,16 +229,15 @@ func AssetDir(name string) ([]string, error) { } type _bintree_t struct { - Func func() ([]byte, error) + Func func() ([]byte, error) Children map[string]*_bintree_t } + var _bintree = &_bintree_t{nil, map[string]*_bintree_t{ "sqlc": &_bintree_t{nil, map[string]*_bintree_t{ "tmpl": &_bintree_t{nil, map[string]*_bintree_t{ - "fields.tmpl": &_bintree_t{sqlc_tmpl_fields_tmpl, map[string]*_bintree_t{ - }}, - "schema.tmpl": &_bintree_t{sqlc_tmpl_schema_tmpl, map[string]*_bintree_t{ - }}, + "fields.tmpl": &_bintree_t{sqlc_tmpl_fields_tmpl, map[string]*_bintree_t{}}, + "schema.tmpl": &_bintree_t{sqlc_tmpl_schema_tmpl, map[string]*_bintree_t{}}, }}, }}, }} diff --git a/sqlc/tmpl/schema.tmpl b/sqlc/tmpl/schema.tmpl index 99912a0..9f64257 100644 --- a/sqlc/tmpl/schema.tmpl +++ b/sqlc/tmpl/schema.tmpl @@ -6,62 +6,62 @@ package {{ .Package }} import ( - "github.com/relops/sqlc/sqlc" - "strings" + "github.com/shutej/sqlc/sqlc" + "strings" ) {{ range $_, $t := .Tables }} type {{ toLower $t.Name }} struct { - {{ range $_, $f := $t.Fields }} - {{ toUpper $f.Name }} sqlc.{{ $f.Type }}Field - {{ end }} - alias string + {{ range $_, $f := $t.Fields }} + {{ toUpper $f.Name }} sqlc.{{ $f.Type }}Field + {{ end }} + alias string } func (t *{{ toLower $t.Name }}) IsSelectable() {} func (t *{{ toLower $t.Name }}) Name() string { - return "{{ toLower $t.Name }}" + return "{{ toLower $t.Name }}" } func (t *{{ toLower $t.Name }}) As(a string) sqlc.Selectable { - return &{{ toLower $t.Name }}{ - {{ range $_, $f := $t.Fields }} - {{ toUpper $f.Name }}: t.{{ toUpper $f.Name }}, - {{ end }} - alias:a, - } + return &{{ toLower $t.Name }}{ + {{ range $_, $f := $t.Fields }} + {{ toUpper $f.Name }}: t.{{ toUpper $f.Name }}, + {{ end }} + alias:a, + } } func (t *{{ toLower $t.Name }}) Alias() string { - return t.alias + return t.alias } func (t *{{ toLower $t.Name }}) MaybeAlias() string { - if t.alias == "" { - return "{{ toLower $t.Name }}" - } else { - return t.alias - } + if t.alias == "" { + return "{{ toLower $t.Name }}" + } else { + return t.alias + } } ///// {{ range $_, $ty := $types }} func (t *{{ toLower $t.Name }}) {{ $ty.Prefix }}Field(name string) sqlc.{{ $ty.Prefix }}Field { - return sqlc.{{ $ty.Prefix }}({{ toUpper $t.Name }}, strings.ToUpper(name)) + return sqlc.{{ $ty.Prefix }}({{ toUpper $t.Name }}, strings.ToUpper(name)) } {{ end }} ///// func (t *{{ toLower $t.Name }}) Fields() []sqlc.Field { - return []sqlc.Field{ - {{ range $_, $f := $t.Fields }} - sqlc.{{ $f.Type }}({{ toUpper $t.Name }}, "{{ toUpper $f.Name }}"), - {{ end }} - } + return []sqlc.Field{ + {{ range $_, $f := $t.Fields }} + sqlc.{{ $f.Type }}({{ toUpper $t.Name }}, "{{ toUpper $f.Name }}"), + {{ end }} + } } {{ end }} @@ -69,9 +69,9 @@ func (t *{{ toLower $t.Name }}) Fields() []sqlc.Field { {{ range $_, $t := .Tables }} var __{{ toLower $t.Name }} = &{{ toLower $t.Name }}{} var {{ toUpper $t.Name }} = &{{ toLower $t.Name }} { - + {{ range $_, $f := $t.Fields }} - {{ toUpper $f.Name }}: sqlc.{{ $f.Type }}(__{{ toLower $t.Name }}, "{{ toUpper $f.Name }}"), + {{ toUpper $f.Name }}: sqlc.{{ $f.Type }}(__{{ toLower $t.Name }}, "{{ toUpper $f.Name }}"), {{ end }} } From 911156510ec49b3544d83a808058c061cf4b1a27 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Thu, 8 Jan 2015 12:37:53 -0500 Subject: [PATCH 03/17] added schema qualification and reflection support --- meta/types.go | 5 + sqlc/fields.go | 1551 +++++++++++++++++++++++------------------ sqlc/generator.go | 1 + sqlc/schema.go | 285 ++++---- sqlc/sqlc.go | 13 + sqlc/tmpl/fields.tmpl | 165 +++-- sqlc/tmpl/schema.tmpl | 16 +- 7 files changed, 1136 insertions(+), 900 deletions(-) diff --git a/meta/types.go b/meta/types.go index 4e7ff33..1d4bcdc 100644 --- a/meta/types.go +++ b/meta/types.go @@ -1,8 +1,13 @@ package meta +import ( + "reflect" +) + type TypeInfo struct { Prefix string Literal string + Type reflect.Type } var Types = []TypeInfo{ diff --git a/sqlc/fields.go b/sqlc/fields.go index 2aeb5fd..444b80c 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -1,1451 +1,1628 @@ // THIS FILE WAS AUTOGENERATED - ANY EDITS TO THIS WILL BE LOST WHEN IT IS REGENERATED -package sqlc - -import ( - "time" -) - -type InsertSetStep interface { - SetString(StringField, string) InsertSetMoreStep - SetBool(BoolField, bool) InsertSetMoreStep - SetInt(IntField, int) InsertSetMoreStep - SetInt64(Int64Field, int64) InsertSetMoreStep +package sqlc - SetFloat32(Float32Field, float32) InsertSetMoreStep +import ( + "reflect" + "time" +) - SetFloat64(Float64Field, float64) InsertSetMoreStep +var ( + typeString = reflect.TypeOf("") + typeBool = reflect.TypeOf(false) + typeInt = reflect.TypeOf(int(0)) + typeInt64 = reflect.TypeOf(int64(0)) + typeFloat32 = reflect.TypeOf(float32(0.)) + typeFloat64 = reflect.TypeOf(float64(0.)) + typeTime = reflect.TypeOf(time.Unix(0, 0)) +) - SetTime(TimeField, time.Time) InsertSetMoreStep +type InsertSetStep interface { + + SetString(StringField, string) InsertSetMoreStep + + SetBool(BoolField, bool) InsertSetMoreStep + + SetInt(IntField, int) InsertSetMoreStep + + SetInt64(Int64Field, int64) InsertSetMoreStep + + SetFloat32(Float32Field, float32) InsertSetMoreStep + + SetFloat64(Float64Field, float64) InsertSetMoreStep + + SetTime(TimeField, time.Time) InsertSetMoreStep + } type UpdateSetStep interface { - SetString(StringField, string) UpdateSetMoreStep - - SetBool(BoolField, bool) UpdateSetMoreStep - - SetInt(IntField, int) UpdateSetMoreStep - - SetInt64(Int64Field, int64) UpdateSetMoreStep - - SetFloat32(Float32Field, float32) UpdateSetMoreStep - - SetFloat64(Float64Field, float64) UpdateSetMoreStep - - SetTime(TimeField, time.Time) UpdateSetMoreStep + + SetString(StringField, string) UpdateSetMoreStep + + SetBool(BoolField, bool) UpdateSetMoreStep + + SetInt(IntField, int) UpdateSetMoreStep + + SetInt64(Int64Field, int64) UpdateSetMoreStep + + SetFloat32(Float32Field, float32) UpdateSetMoreStep + + SetFloat64(Float64Field, float64) UpdateSetMoreStep + + SetTime(TimeField, time.Time) UpdateSetMoreStep + } + func (i *insert) SetString(f StringField, v string) InsertSetMoreStep { - return i.set(f, v) + return i.set(f,v) } func (i *insert) SetBool(f BoolField, v bool) InsertSetMoreStep { - return i.set(f, v) + return i.set(f,v) } func (i *insert) SetInt(f IntField, v int) InsertSetMoreStep { - return i.set(f, v) + return i.set(f,v) } func (i *insert) SetInt64(f Int64Field, v int64) InsertSetMoreStep { - return i.set(f, v) + return i.set(f,v) } func (i *insert) SetFloat32(f Float32Field, v float32) InsertSetMoreStep { - return i.set(f, v) + return i.set(f,v) } func (i *insert) SetFloat64(f Float64Field, v float64) InsertSetMoreStep { - return i.set(f, v) + return i.set(f,v) } func (i *insert) SetTime(f TimeField, v time.Time) InsertSetMoreStep { - return i.set(f, v) + return i.set(f,v) } + + func (u *update) SetString(f StringField, v string) UpdateSetMoreStep { - return u.set(f, v) + return u.set(f,v) } func (u *update) SetBool(f BoolField, v bool) UpdateSetMoreStep { - return u.set(f, v) + return u.set(f,v) } func (u *update) SetInt(f IntField, v int) UpdateSetMoreStep { - return u.set(f, v) + return u.set(f,v) } func (u *update) SetInt64(f Int64Field, v int64) UpdateSetMoreStep { - return u.set(f, v) + return u.set(f,v) } func (u *update) SetFloat32(f Float32Field, v float32) UpdateSetMoreStep { - return u.set(f, v) + return u.set(f,v) } func (u *update) SetFloat64(f Float64Field, v float64) UpdateSetMoreStep { - return u.set(f, v) + return u.set(f,v) } func (u *update) SetTime(f TimeField, v time.Time) UpdateSetMoreStep { - return u.set(f, v) + return u.set(f,v) } + ///// type Reflectable interface { - StringField(name string) StringField - BoolField(name string) BoolField + StringField(name string) StringField - IntField(name string) IntField + BoolField(name string) BoolField - Int64Field(name string) Int64Field + IntField(name string) IntField - Float32Field(name string) Float32Field + Int64Field(name string) Int64Field - Float64Field(name string) Float64Field + Float32Field(name string) Float32Field + + Float64Field(name string) Float64Field + + TimeField(name string) TimeField - TimeField(name string) TimeField } type Functional interface { - Avg() Field - Max() Field + Avg() Field + + Max() Field - Min() Field + Min() Field - Ceil() Field + Ceil() Field - Div(_0 interface{}) Field + Div(_0 interface{}) Field - Cast(_0 interface{}) Field + Cast(_0 interface{}) Field - Md5() Field + Md5() Field - Lower() Field + Lower() Field + + Hex() Field - Hex() Field } + func (s *selection) StringField(name string) StringField { - return &stringField{name: name} + return &stringField{name: name} } func (t table) StringField(name string) StringField { - return &stringField{name: name, selection: t} + return &stringField{name: name, selection: t} } func (s *selection) BoolField(name string) BoolField { - return &boolField{name: name} + return &boolField{name: name} } func (t table) BoolField(name string) BoolField { - return &boolField{name: name, selection: t} + return &boolField{name: name, selection: t} } func (s *selection) IntField(name string) IntField { - return &intField{name: name} + return &intField{name: name} } func (t table) IntField(name string) IntField { - return &intField{name: name, selection: t} + return &intField{name: name, selection: t} } func (s *selection) Int64Field(name string) Int64Field { - return &int64Field{name: name} + return &int64Field{name: name} } func (t table) Int64Field(name string) Int64Field { - return &int64Field{name: name, selection: t} + return &int64Field{name: name, selection: t} } func (s *selection) Float32Field(name string) Float32Field { - return &float32Field{name: name} + return &float32Field{name: name} } func (t table) Float32Field(name string) Float32Field { - return &float32Field{name: name, selection: t} + return &float32Field{name: name, selection: t} } func (s *selection) Float64Field(name string) Float64Field { - return &float64Field{name: name} + return &float64Field{name: name} } func (t table) Float64Field(name string) Float64Field { - return &float64Field{name: name, selection: t} + return &float64Field{name: name, selection: t} } func (s *selection) TimeField(name string) TimeField { - return &timeField{name: name} + return &timeField{name: name} } func (t table) TimeField(name string) TimeField { - return &timeField{name: name, selection: t} + return &timeField{name: name, selection: t} } + ///// + + type stringField struct { - name string - selection Selectable - alias string - fun FieldFunction + name string + selection Selectable + alias string + fun FieldFunction } type StringField interface { - TableField - - Eq(value string) Condition - IsEq(value StringField) JoinCondition - - Gt(value string) Condition - IsGt(value StringField) JoinCondition - - Ge(value string) Condition - IsGe(value StringField) JoinCondition - - Lt(value string) Condition - IsLt(value StringField) JoinCondition - - Le(value string) Condition - IsLe(value StringField) JoinCondition + TableField + + Eq(value string) Condition + IsEq(value StringField) JoinCondition + + Gt(value string) Condition + IsGt(value StringField) JoinCondition + + Ge(value string) Condition + IsGe(value StringField) JoinCondition + + Lt(value string) Condition + IsLt(value StringField) JoinCondition + + Le(value string) Condition + IsLe(value StringField) JoinCondition + } func (c *stringField) Function() FieldFunction { - return FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - } + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } } func (c *stringField) fct(fun, expr string, args ...interface{}) Field { - if &c.fun == nil { - return &stringField{ - name: c.name, - selection: c.selection, - fun: FieldFunction{Name: fun, Expr: expr, Args: args}, - } - } else { - return &stringField{ - name: c.name, - selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, - Child: &FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - }, - } - } + if &c.fun == nil { + return &stringField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &stringField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } } func (c *stringField) As(alias string) Field { - return &stringField{ - name: c.name, - selection: c.selection, - alias: alias, - fun: FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - } + return &stringField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } } func (c *stringField) Alias() string { - return c.alias + return c.alias } func (c *stringField) MaybeAlias() string { - if c.alias == "" { - return c.name - } else { - return c.alias - } + if c.alias == "" { + return c.name + } else { + return c.alias + } } func (c *stringField) Name() string { - return c.name + return c.name +} + +func (c *stringField) Type() reflect.Type { + return typeString } func (c *stringField) Parent() Selectable { - return c.selection + return c.selection } // -- + + func (c *stringField) Eq(pred string) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } func (c *stringField) IsEq(pred StringField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } + + func (c *stringField) Gt(pred string) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } func (c *stringField) IsGt(pred StringField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } + + func (c *stringField) Ge(pred string) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } func (c *stringField) IsGe(pred StringField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } + + func (c *stringField) Lt(pred string) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } func (c *stringField) IsLt(pred StringField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } + + func (c *stringField) Le(pred string) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } func (c *stringField) IsLe(pred StringField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } + + // -- func String(s Selectable, name string) StringField { - return &stringField{name: name, selection: s} + return &stringField{name: name, selection: s} } ////// + func (c *stringField) Avg() Field { - return c.fct("Avg", "AVG(%s)") + return c.fct("Avg", "AVG(%s)") } func (c *stringField) Max() Field { - return c.fct("Max", "MAX(%s)") + return c.fct("Max", "MAX(%s)") } func (c *stringField) Min() Field { - return c.fct("Min", "MIN(%s)") + return c.fct("Min", "MIN(%s)") } func (c *stringField) Ceil() Field { - return c.fct("Ceil", "CEIL(%s)") + return c.fct("Ceil", "CEIL(%s)") } func (c *stringField) Div(_0 interface{}) Field { - return c.fct("Div", "%s / %v", _0) + return c.fct("Div", "%s / %v", _0) } func (c *stringField) Cast(_0 interface{}) Field { - return c.fct("Cast", "CAST(%s AS %s)", _0) + return c.fct("Cast", "CAST(%s AS %s)", _0) } func (c *stringField) Md5() Field { - return c.fct("Md5", "MD5(%s)") + return c.fct("Md5", "MD5(%s)") } func (c *stringField) Lower() Field { - return c.fct("Lower", "LOWER(%s)") + return c.fct("Lower", "LOWER(%s)") } func (c *stringField) Hex() Field { - return c.fct("Hex", "HEX(%s)") -} - -type boolField struct { - name string - selection Selectable - alias string - fun FieldFunction + return c.fct("Hex", "HEX(%s)") } -type BoolField interface { - TableField - - Eq(value bool) Condition - IsEq(value BoolField) JoinCondition - Gt(value bool) Condition - IsGt(value BoolField) JoinCondition - Ge(value bool) Condition - IsGe(value BoolField) JoinCondition - Lt(value bool) Condition - IsLt(value BoolField) JoinCondition +type boolField struct { + name string + selection Selectable + alias string + fun FieldFunction +} - Le(value bool) Condition - IsLe(value BoolField) JoinCondition +type BoolField interface { + TableField + + Eq(value bool) Condition + IsEq(value BoolField) JoinCondition + + Gt(value bool) Condition + IsGt(value BoolField) JoinCondition + + Ge(value bool) Condition + IsGe(value BoolField) JoinCondition + + Lt(value bool) Condition + IsLt(value BoolField) JoinCondition + + Le(value bool) Condition + IsLe(value BoolField) JoinCondition + } func (c *boolField) Function() FieldFunction { - return FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - } + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } } func (c *boolField) fct(fun, expr string, args ...interface{}) Field { - if &c.fun == nil { - return &boolField{ - name: c.name, - selection: c.selection, - fun: FieldFunction{Name: fun, Expr: expr, Args: args}, - } - } else { - return &boolField{ - name: c.name, - selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, - Child: &FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - }, - } - } + if &c.fun == nil { + return &boolField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &boolField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } } func (c *boolField) As(alias string) Field { - return &boolField{ - name: c.name, - selection: c.selection, - alias: alias, - fun: FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - } + return &boolField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } } func (c *boolField) Alias() string { - return c.alias + return c.alias } func (c *boolField) MaybeAlias() string { - if c.alias == "" { - return c.name - } else { - return c.alias - } + if c.alias == "" { + return c.name + } else { + return c.alias + } } func (c *boolField) Name() string { - return c.name + return c.name +} + +func (c *boolField) Type() reflect.Type { + return typeBool } func (c *boolField) Parent() Selectable { - return c.selection + return c.selection } // -- + + func (c *boolField) Eq(pred bool) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } func (c *boolField) IsEq(pred BoolField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } + + func (c *boolField) Gt(pred bool) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } func (c *boolField) IsGt(pred BoolField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } + + func (c *boolField) Ge(pred bool) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } func (c *boolField) IsGe(pred BoolField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } + + func (c *boolField) Lt(pred bool) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } func (c *boolField) IsLt(pred BoolField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } + + func (c *boolField) Le(pred bool) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } func (c *boolField) IsLe(pred BoolField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } + + // -- func Bool(s Selectable, name string) BoolField { - return &boolField{name: name, selection: s} + return &boolField{name: name, selection: s} } ////// + func (c *boolField) Avg() Field { - return c.fct("Avg", "AVG(%s)") + return c.fct("Avg", "AVG(%s)") } func (c *boolField) Max() Field { - return c.fct("Max", "MAX(%s)") + return c.fct("Max", "MAX(%s)") } func (c *boolField) Min() Field { - return c.fct("Min", "MIN(%s)") + return c.fct("Min", "MIN(%s)") } func (c *boolField) Ceil() Field { - return c.fct("Ceil", "CEIL(%s)") + return c.fct("Ceil", "CEIL(%s)") } func (c *boolField) Div(_0 interface{}) Field { - return c.fct("Div", "%s / %v", _0) + return c.fct("Div", "%s / %v", _0) } func (c *boolField) Cast(_0 interface{}) Field { - return c.fct("Cast", "CAST(%s AS %s)", _0) + return c.fct("Cast", "CAST(%s AS %s)", _0) } func (c *boolField) Md5() Field { - return c.fct("Md5", "MD5(%s)") + return c.fct("Md5", "MD5(%s)") } func (c *boolField) Lower() Field { - return c.fct("Lower", "LOWER(%s)") + return c.fct("Lower", "LOWER(%s)") } func (c *boolField) Hex() Field { - return c.fct("Hex", "HEX(%s)") + return c.fct("Hex", "HEX(%s)") } -type intField struct { - name string - selection Selectable - alias string - fun FieldFunction -} - -type IntField interface { - TableField - - Eq(value int) Condition - IsEq(value IntField) JoinCondition - Gt(value int) Condition - IsGt(value IntField) JoinCondition - Ge(value int) Condition - IsGe(value IntField) JoinCondition - Lt(value int) Condition - IsLt(value IntField) JoinCondition +type intField struct { + name string + selection Selectable + alias string + fun FieldFunction +} - Le(value int) Condition - IsLe(value IntField) JoinCondition +type IntField interface { + TableField + + Eq(value int) Condition + IsEq(value IntField) JoinCondition + + Gt(value int) Condition + IsGt(value IntField) JoinCondition + + Ge(value int) Condition + IsGe(value IntField) JoinCondition + + Lt(value int) Condition + IsLt(value IntField) JoinCondition + + Le(value int) Condition + IsLe(value IntField) JoinCondition + } func (c *intField) Function() FieldFunction { - return FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - } + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } } func (c *intField) fct(fun, expr string, args ...interface{}) Field { - if &c.fun == nil { - return &intField{ - name: c.name, - selection: c.selection, - fun: FieldFunction{Name: fun, Expr: expr, Args: args}, - } - } else { - return &intField{ - name: c.name, - selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, - Child: &FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - }, - } - } + if &c.fun == nil { + return &intField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &intField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } } func (c *intField) As(alias string) Field { - return &intField{ - name: c.name, - selection: c.selection, - alias: alias, - fun: FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - } + return &intField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } } func (c *intField) Alias() string { - return c.alias + return c.alias } func (c *intField) MaybeAlias() string { - if c.alias == "" { - return c.name - } else { - return c.alias - } + if c.alias == "" { + return c.name + } else { + return c.alias + } } func (c *intField) Name() string { - return c.name + return c.name +} + +func (c *intField) Type() reflect.Type { + return typeInt } func (c *intField) Parent() Selectable { - return c.selection + return c.selection } // -- + + func (c *intField) Eq(pred int) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } func (c *intField) IsEq(pred IntField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } + + func (c *intField) Gt(pred int) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } func (c *intField) IsGt(pred IntField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } + + func (c *intField) Ge(pred int) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } func (c *intField) IsGe(pred IntField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } + + func (c *intField) Lt(pred int) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } func (c *intField) IsLt(pred IntField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } + + func (c *intField) Le(pred int) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } func (c *intField) IsLe(pred IntField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } + + // -- func Int(s Selectable, name string) IntField { - return &intField{name: name, selection: s} + return &intField{name: name, selection: s} } ////// + func (c *intField) Avg() Field { - return c.fct("Avg", "AVG(%s)") + return c.fct("Avg", "AVG(%s)") } func (c *intField) Max() Field { - return c.fct("Max", "MAX(%s)") + return c.fct("Max", "MAX(%s)") } func (c *intField) Min() Field { - return c.fct("Min", "MIN(%s)") + return c.fct("Min", "MIN(%s)") } func (c *intField) Ceil() Field { - return c.fct("Ceil", "CEIL(%s)") + return c.fct("Ceil", "CEIL(%s)") } func (c *intField) Div(_0 interface{}) Field { - return c.fct("Div", "%s / %v", _0) + return c.fct("Div", "%s / %v", _0) } func (c *intField) Cast(_0 interface{}) Field { - return c.fct("Cast", "CAST(%s AS %s)", _0) + return c.fct("Cast", "CAST(%s AS %s)", _0) } func (c *intField) Md5() Field { - return c.fct("Md5", "MD5(%s)") + return c.fct("Md5", "MD5(%s)") } func (c *intField) Lower() Field { - return c.fct("Lower", "LOWER(%s)") + return c.fct("Lower", "LOWER(%s)") } func (c *intField) Hex() Field { - return c.fct("Hex", "HEX(%s)") + return c.fct("Hex", "HEX(%s)") } -type int64Field struct { - name string - selection Selectable - alias string - fun FieldFunction -} - -type Int64Field interface { - TableField - - Eq(value int64) Condition - IsEq(value Int64Field) JoinCondition - Gt(value int64) Condition - IsGt(value Int64Field) JoinCondition - Ge(value int64) Condition - IsGe(value Int64Field) JoinCondition - Lt(value int64) Condition - IsLt(value Int64Field) JoinCondition +type int64Field struct { + name string + selection Selectable + alias string + fun FieldFunction +} - Le(value int64) Condition - IsLe(value Int64Field) JoinCondition +type Int64Field interface { + TableField + + Eq(value int64) Condition + IsEq(value Int64Field) JoinCondition + + Gt(value int64) Condition + IsGt(value Int64Field) JoinCondition + + Ge(value int64) Condition + IsGe(value Int64Field) JoinCondition + + Lt(value int64) Condition + IsLt(value Int64Field) JoinCondition + + Le(value int64) Condition + IsLe(value Int64Field) JoinCondition + } func (c *int64Field) Function() FieldFunction { - return FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - } + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } } func (c *int64Field) fct(fun, expr string, args ...interface{}) Field { - if &c.fun == nil { - return &int64Field{ - name: c.name, - selection: c.selection, - fun: FieldFunction{Name: fun, Expr: expr, Args: args}, - } - } else { - return &int64Field{ - name: c.name, - selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, - Child: &FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - }, - } - } + if &c.fun == nil { + return &int64Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &int64Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } } func (c *int64Field) As(alias string) Field { - return &int64Field{ - name: c.name, - selection: c.selection, - alias: alias, - fun: FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - } + return &int64Field{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } } func (c *int64Field) Alias() string { - return c.alias + return c.alias } func (c *int64Field) MaybeAlias() string { - if c.alias == "" { - return c.name - } else { - return c.alias - } + if c.alias == "" { + return c.name + } else { + return c.alias + } } func (c *int64Field) Name() string { - return c.name + return c.name +} + +func (c *int64Field) Type() reflect.Type { + return typeInt64 } func (c *int64Field) Parent() Selectable { - return c.selection + return c.selection } // -- + + func (c *int64Field) Eq(pred int64) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } func (c *int64Field) IsEq(pred Int64Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } + + func (c *int64Field) Gt(pred int64) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } func (c *int64Field) IsGt(pred Int64Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } + + func (c *int64Field) Ge(pred int64) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } func (c *int64Field) IsGe(pred Int64Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } + + func (c *int64Field) Lt(pred int64) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } func (c *int64Field) IsLt(pred Int64Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } + + func (c *int64Field) Le(pred int64) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } func (c *int64Field) IsLe(pred Int64Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } + + // -- func Int64(s Selectable, name string) Int64Field { - return &int64Field{name: name, selection: s} + return &int64Field{name: name, selection: s} } ////// + func (c *int64Field) Avg() Field { - return c.fct("Avg", "AVG(%s)") + return c.fct("Avg", "AVG(%s)") } func (c *int64Field) Max() Field { - return c.fct("Max", "MAX(%s)") + return c.fct("Max", "MAX(%s)") } func (c *int64Field) Min() Field { - return c.fct("Min", "MIN(%s)") + return c.fct("Min", "MIN(%s)") } func (c *int64Field) Ceil() Field { - return c.fct("Ceil", "CEIL(%s)") + return c.fct("Ceil", "CEIL(%s)") } func (c *int64Field) Div(_0 interface{}) Field { - return c.fct("Div", "%s / %v", _0) + return c.fct("Div", "%s / %v", _0) } func (c *int64Field) Cast(_0 interface{}) Field { - return c.fct("Cast", "CAST(%s AS %s)", _0) + return c.fct("Cast", "CAST(%s AS %s)", _0) } func (c *int64Field) Md5() Field { - return c.fct("Md5", "MD5(%s)") + return c.fct("Md5", "MD5(%s)") } func (c *int64Field) Lower() Field { - return c.fct("Lower", "LOWER(%s)") + return c.fct("Lower", "LOWER(%s)") } func (c *int64Field) Hex() Field { - return c.fct("Hex", "HEX(%s)") -} - -type float32Field struct { - name string - selection Selectable - alias string - fun FieldFunction + return c.fct("Hex", "HEX(%s)") } -type Float32Field interface { - TableField - - Eq(value float32) Condition - IsEq(value Float32Field) JoinCondition - Gt(value float32) Condition - IsGt(value Float32Field) JoinCondition - Ge(value float32) Condition - IsGe(value Float32Field) JoinCondition - Lt(value float32) Condition - IsLt(value Float32Field) JoinCondition +type float32Field struct { + name string + selection Selectable + alias string + fun FieldFunction +} - Le(value float32) Condition - IsLe(value Float32Field) JoinCondition +type Float32Field interface { + TableField + + Eq(value float32) Condition + IsEq(value Float32Field) JoinCondition + + Gt(value float32) Condition + IsGt(value Float32Field) JoinCondition + + Ge(value float32) Condition + IsGe(value Float32Field) JoinCondition + + Lt(value float32) Condition + IsLt(value Float32Field) JoinCondition + + Le(value float32) Condition + IsLe(value Float32Field) JoinCondition + } func (c *float32Field) Function() FieldFunction { - return FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - } + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } } func (c *float32Field) fct(fun, expr string, args ...interface{}) Field { - if &c.fun == nil { - return &float32Field{ - name: c.name, - selection: c.selection, - fun: FieldFunction{Name: fun, Expr: expr, Args: args}, - } - } else { - return &float32Field{ - name: c.name, - selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, - Child: &FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - }, - } - } + if &c.fun == nil { + return &float32Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &float32Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } } func (c *float32Field) As(alias string) Field { - return &float32Field{ - name: c.name, - selection: c.selection, - alias: alias, - fun: FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - } + return &float32Field{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } } func (c *float32Field) Alias() string { - return c.alias + return c.alias } func (c *float32Field) MaybeAlias() string { - if c.alias == "" { - return c.name - } else { - return c.alias - } + if c.alias == "" { + return c.name + } else { + return c.alias + } } func (c *float32Field) Name() string { - return c.name + return c.name +} + +func (c *float32Field) Type() reflect.Type { + return typeFloat32 } func (c *float32Field) Parent() Selectable { - return c.selection + return c.selection } // -- + + func (c *float32Field) Eq(pred float32) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } func (c *float32Field) IsEq(pred Float32Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } + + func (c *float32Field) Gt(pred float32) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } func (c *float32Field) IsGt(pred Float32Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } + + func (c *float32Field) Ge(pred float32) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } func (c *float32Field) IsGe(pred Float32Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } + + func (c *float32Field) Lt(pred float32) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } func (c *float32Field) IsLt(pred Float32Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } + + func (c *float32Field) Le(pred float32) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } func (c *float32Field) IsLe(pred Float32Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } + + // -- func Float32(s Selectable, name string) Float32Field { - return &float32Field{name: name, selection: s} + return &float32Field{name: name, selection: s} } ////// + func (c *float32Field) Avg() Field { - return c.fct("Avg", "AVG(%s)") + return c.fct("Avg", "AVG(%s)") } func (c *float32Field) Max() Field { - return c.fct("Max", "MAX(%s)") + return c.fct("Max", "MAX(%s)") } func (c *float32Field) Min() Field { - return c.fct("Min", "MIN(%s)") + return c.fct("Min", "MIN(%s)") } func (c *float32Field) Ceil() Field { - return c.fct("Ceil", "CEIL(%s)") + return c.fct("Ceil", "CEIL(%s)") } func (c *float32Field) Div(_0 interface{}) Field { - return c.fct("Div", "%s / %v", _0) + return c.fct("Div", "%s / %v", _0) } func (c *float32Field) Cast(_0 interface{}) Field { - return c.fct("Cast", "CAST(%s AS %s)", _0) + return c.fct("Cast", "CAST(%s AS %s)", _0) } func (c *float32Field) Md5() Field { - return c.fct("Md5", "MD5(%s)") + return c.fct("Md5", "MD5(%s)") } func (c *float32Field) Lower() Field { - return c.fct("Lower", "LOWER(%s)") + return c.fct("Lower", "LOWER(%s)") } func (c *float32Field) Hex() Field { - return c.fct("Hex", "HEX(%s)") + return c.fct("Hex", "HEX(%s)") } -type float64Field struct { - name string - selection Selectable - alias string - fun FieldFunction -} -type Float64Field interface { - TableField - - Eq(value float64) Condition - IsEq(value Float64Field) JoinCondition - - Gt(value float64) Condition - IsGt(value Float64Field) JoinCondition - Ge(value float64) Condition - IsGe(value Float64Field) JoinCondition - Lt(value float64) Condition - IsLt(value Float64Field) JoinCondition +type float64Field struct { + name string + selection Selectable + alias string + fun FieldFunction +} - Le(value float64) Condition - IsLe(value Float64Field) JoinCondition +type Float64Field interface { + TableField + + Eq(value float64) Condition + IsEq(value Float64Field) JoinCondition + + Gt(value float64) Condition + IsGt(value Float64Field) JoinCondition + + Ge(value float64) Condition + IsGe(value Float64Field) JoinCondition + + Lt(value float64) Condition + IsLt(value Float64Field) JoinCondition + + Le(value float64) Condition + IsLe(value Float64Field) JoinCondition + } func (c *float64Field) Function() FieldFunction { - return FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - } + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } } func (c *float64Field) fct(fun, expr string, args ...interface{}) Field { - if &c.fun == nil { - return &float64Field{ - name: c.name, - selection: c.selection, - fun: FieldFunction{Name: fun, Expr: expr, Args: args}, - } - } else { - return &float64Field{ - name: c.name, - selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, - Child: &FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - }, - } - } + if &c.fun == nil { + return &float64Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &float64Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } } func (c *float64Field) As(alias string) Field { - return &float64Field{ - name: c.name, - selection: c.selection, - alias: alias, - fun: FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - } + return &float64Field{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } } func (c *float64Field) Alias() string { - return c.alias + return c.alias } func (c *float64Field) MaybeAlias() string { - if c.alias == "" { - return c.name - } else { - return c.alias - } + if c.alias == "" { + return c.name + } else { + return c.alias + } } func (c *float64Field) Name() string { - return c.name + return c.name +} + +func (c *float64Field) Type() reflect.Type { + return typeFloat64 } func (c *float64Field) Parent() Selectable { - return c.selection + return c.selection } // -- + + func (c *float64Field) Eq(pred float64) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } func (c *float64Field) IsEq(pred Float64Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } + + func (c *float64Field) Gt(pred float64) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } func (c *float64Field) IsGt(pred Float64Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } + + func (c *float64Field) Ge(pred float64) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } func (c *float64Field) IsGe(pred Float64Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } + + func (c *float64Field) Lt(pred float64) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } func (c *float64Field) IsLt(pred Float64Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } + + func (c *float64Field) Le(pred float64) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } func (c *float64Field) IsLe(pred Float64Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } + + // -- func Float64(s Selectable, name string) Float64Field { - return &float64Field{name: name, selection: s} + return &float64Field{name: name, selection: s} } ////// + func (c *float64Field) Avg() Field { - return c.fct("Avg", "AVG(%s)") + return c.fct("Avg", "AVG(%s)") } func (c *float64Field) Max() Field { - return c.fct("Max", "MAX(%s)") + return c.fct("Max", "MAX(%s)") } func (c *float64Field) Min() Field { - return c.fct("Min", "MIN(%s)") + return c.fct("Min", "MIN(%s)") } func (c *float64Field) Ceil() Field { - return c.fct("Ceil", "CEIL(%s)") + return c.fct("Ceil", "CEIL(%s)") } func (c *float64Field) Div(_0 interface{}) Field { - return c.fct("Div", "%s / %v", _0) + return c.fct("Div", "%s / %v", _0) } func (c *float64Field) Cast(_0 interface{}) Field { - return c.fct("Cast", "CAST(%s AS %s)", _0) + return c.fct("Cast", "CAST(%s AS %s)", _0) } func (c *float64Field) Md5() Field { - return c.fct("Md5", "MD5(%s)") + return c.fct("Md5", "MD5(%s)") } func (c *float64Field) Lower() Field { - return c.fct("Lower", "LOWER(%s)") + return c.fct("Lower", "LOWER(%s)") } func (c *float64Field) Hex() Field { - return c.fct("Hex", "HEX(%s)") + return c.fct("Hex", "HEX(%s)") } -type timeField struct { - name string - selection Selectable - alias string - fun FieldFunction -} -type TimeField interface { - TableField - Eq(value time.Time) Condition - IsEq(value TimeField) JoinCondition - Gt(value time.Time) Condition - IsGt(value TimeField) JoinCondition - - Ge(value time.Time) Condition - IsGe(value TimeField) JoinCondition - - Lt(value time.Time) Condition - IsLt(value TimeField) JoinCondition +type timeField struct { + name string + selection Selectable + alias string + fun FieldFunction +} - Le(value time.Time) Condition - IsLe(value TimeField) JoinCondition +type TimeField interface { + TableField + + Eq(value time.Time) Condition + IsEq(value TimeField) JoinCondition + + Gt(value time.Time) Condition + IsGt(value TimeField) JoinCondition + + Ge(value time.Time) Condition + IsGe(value TimeField) JoinCondition + + Lt(value time.Time) Condition + IsLt(value TimeField) JoinCondition + + Le(value time.Time) Condition + IsLe(value TimeField) JoinCondition + } func (c *timeField) Function() FieldFunction { - return FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - } + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } } func (c *timeField) fct(fun, expr string, args ...interface{}) Field { - if &c.fun == nil { - return &timeField{ - name: c.name, - selection: c.selection, - fun: FieldFunction{Name: fun, Expr: expr, Args: args}, - } - } else { - return &timeField{ - name: c.name, - selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, - Child: &FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - }, - } - } + if &c.fun == nil { + return &timeField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &timeField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } } func (c *timeField) As(alias string) Field { - return &timeField{ - name: c.name, - selection: c.selection, - alias: alias, - fun: FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - } + return &timeField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } } func (c *timeField) Alias() string { - return c.alias + return c.alias } func (c *timeField) MaybeAlias() string { - if c.alias == "" { - return c.name - } else { - return c.alias - } + if c.alias == "" { + return c.name + } else { + return c.alias + } } func (c *timeField) Name() string { - return c.name + return c.name +} + +func (c *timeField) Type() reflect.Type { + return typeTime } func (c *timeField) Parent() Selectable { - return c.selection + return c.selection } // -- + + func (c *timeField) Eq(pred time.Time) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } func (c *timeField) IsEq(pred TimeField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } + + func (c *timeField) Gt(pred time.Time) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } func (c *timeField) IsGt(pred TimeField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } + + func (c *timeField) Ge(pred time.Time) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } func (c *timeField) IsGe(pred TimeField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } + + func (c *timeField) Lt(pred time.Time) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } func (c *timeField) IsLt(pred TimeField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } + + func (c *timeField) Le(pred time.Time) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } func (c *timeField) IsLe(pred TimeField) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } + + // -- func Time(s Selectable, name string) TimeField { - return &timeField{name: name, selection: s} + return &timeField{name: name, selection: s} } ////// + func (c *timeField) Avg() Field { - return c.fct("Avg", "AVG(%s)") + return c.fct("Avg", "AVG(%s)") } func (c *timeField) Max() Field { - return c.fct("Max", "MAX(%s)") + return c.fct("Max", "MAX(%s)") } func (c *timeField) Min() Field { - return c.fct("Min", "MIN(%s)") + return c.fct("Min", "MIN(%s)") } func (c *timeField) Ceil() Field { - return c.fct("Ceil", "CEIL(%s)") + return c.fct("Ceil", "CEIL(%s)") } func (c *timeField) Div(_0 interface{}) Field { - return c.fct("Div", "%s / %v", _0) + return c.fct("Div", "%s / %v", _0) } func (c *timeField) Cast(_0 interface{}) Field { - return c.fct("Cast", "CAST(%s AS %s)", _0) + return c.fct("Cast", "CAST(%s AS %s)", _0) } func (c *timeField) Md5() Field { - return c.fct("Md5", "MD5(%s)") + return c.fct("Md5", "MD5(%s)") } func (c *timeField) Lower() Field { - return c.fct("Lower", "LOWER(%s)") + return c.fct("Lower", "LOWER(%s)") } func (c *timeField) Hex() Field { - return c.fct("Hex", "HEX(%s)") + return c.fct("Hex", "HEX(%s)") } + + + diff --git a/sqlc/generator.go b/sqlc/generator.go index 3bd6a0a..80c603e 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -104,6 +104,7 @@ func Generate(db *sql.DB, version string, opts *Options) error { } params := make(map[string]interface{}) + params["Schema"] = opts.Schema params["Tables"] = tables params["Package"] = opts.Package params["Types"] = meta.Types diff --git a/sqlc/schema.go b/sqlc/schema.go index 380268f..8d16dbf 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -27,89 +27,99 @@ func bindata_read(data []byte, name string) ([]byte, error) { func sqlc_tmpl_fields_tmpl() ([]byte, error) { return bindata_read([]byte{ - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0xc4, 0x57, - 0x51, 0x6f, 0xdb, 0x36, 0x10, 0x7e, 0x96, 0x7e, 0xc5, 0xc1, 0x08, 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a5, 0x5c, - 0x31, 0xb9, 0x92, 0xac, 0x00, 0x2e, 0x24, 0x2b, 0xb3, 0x24, 0x65, 0x50, - 0xfb, 0x1e, 0x7a, 0x2f, 0x13, 0x81, 0x2e, 0xae, 0xfe, 0x08, 0xe1, 0x4a, - 0xaa, 0x18, 0xb4, 0x47, 0xf9, 0x07, 0x0f, 0xf7, 0x50, 0x7c, 0x19, 0x3d, - 0x95, 0x2c, 0xe3, 0x5f, 0xd0, 0x38, 0x3e, 0x18, 0x3f, 0x70, 0x96, 0x6f, - 0x42, 0xd0, 0xd6, 0x39, 0x47, 0xd7, 0x49, 0x8e, 0xe6, 0xe0, 0x5b, 0xd0, - 0x0f, 0xbb, 0x92, 0x51, 0x60, 0x74, 0x87, 0xab, 0x98, 0xd8, 0x90, 0xeb, - 0xc6, 0x40, 0xfb, 0x58, 0x6c, 0x30, 0xd1, 0x1f, 0x0c, 0xad, 0x0b, 0x3a, - 0x04, 0xed, 0x64, 0x68, 0x2a, 0x01, 0x8c, 0x39, 0xdc, 0x70, 0x95, 0x61, - 0x00, 0x0e, 0x24, 0x19, 0xb8, 0xb1, 0xbc, 0x9e, 0x43, 0x14, 0x25, 0x5f, - 0x32, 0xb9, 0x2f, 0x05, 0xf0, 0xa8, 0x62, 0x72, 0x9c, 0x85, 0xaf, 0x81, - 0xaf, 0x94, 0x60, 0x20, 0x9e, 0x03, 0x70, 0x0f, 0x37, 0x7b, 0x95, 0xe7, - 0x7f, 0x06, 0x78, 0x44, 0x97, 0x05, 0x70, 0x3f, 0x00, 0xf0, 0x8e, 0x3e, - 0xa6, 0xc6, 0x4b, 0x96, 0xe5, 0x2c, 0x95, 0xc9, 0xa7, 0x9c, 0xf5, 0x2a, - 0x7c, 0x32, 0x09, 0xcf, 0x85, 0x6f, 0x2c, 0x92, 0x17, 0x54, 0xbb, 0x2c, - 0xb9, 0xd8, 0x06, 0xce, 0x0c, 0xfc, 0x63, 0x89, 0x3d, 0x98, 0x96, 0xc1, - 0x6c,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xe5, 0xef, 0xd9, 0xd1, 0xec, 0x2d, 0x54, 0xc5, 0x21, 0xa5, - 0x3b, 0x4a, 0x75, 0x4e, 0x88, 0xc6, 0xf8, 0x4b, 0x51, 0x76, 0x46, 0x1a, - 0x90, 0x71, 0x5a, 0x6e, 0xab, 0xce, 0x48, 0x03, 0x32, 0xbe, 0xfd, 0xcc, - 0xf3, 0xcd, 0xc4, 0x18, 0xd5, 0x00, 0xad, 0x97, 0x60, 0xce, 0x52, 0x3c, - 0x88, 0xf6, 0x22, 0x04, 0x86, 0x61, 0x4c, 0x79, 0x43, 0x48, 0xd0, 0x3d, - 0x44, 0x51, 0xd4, 0xd5, 0xad, 0x6e, 0x7b, 0x97, 0x72, 0xe1, 0x19, 0x5c, - 0xab, 0x88, 0x70, 0x7f, 0x0f, 0x82, 0xe7, 0x64, 0x3b, 0x4f, 0xdf, 0xb8, - 0xce, 0xd3, 0x1a, 0x57, 0x9f, 0x34, 0x12, 0x26, 0x63, 0xcf, 0x52, 0x7b, - 0x1a, 0x75, 0x03, 0x35, 0x85, 0x81, 0xcc, 0xfa, 0x03, 0xfa, 0x14, 0x77, - 0x0a, 0xbc, 0x22, 0x8c, 0x32, 0x08, 0x41, 0xd3, 0x44, 0x09, 0x34, 0xb4, - 0x1b, 0x55, 0xd4, 0x00, 0xcb, 0x2b, 0xf6, 0xb3, 0x40, 0xd2, 0x64, 0x5b, - 0x65, 0xc2, 0xaa, 0xc6, 0xa6, 0xc0, 0x1a, 0xb1, 0xb2, 0x98, 0xea, 0x26, - 0xa6, 0xae, 0x5d, 0x65, 0xaf, 0x1d, 0xde, 0xdc, 0xa2, 0xf1, 0x06, 0x74, - 0xe3, 0x0d, 0x48, 0xc7, 0x1b, 0x50, 0x0f, 0x7e, 0x14, 0x73, 0x5e, 0xc7, - 0xdf, 0x05, 0x72, 0x9a, 0x56, 0x63, 0xfb, 0xa0, 0xb0, 0x44, 0x73, 0x2e, - 0xf5, 0x9a, 0x79, 0x43, 0x3a, 0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20, 0x57, + 0x08, 0xad, 0x09, 0xb4, 0x03, 0x2c, 0x54, 0xf7, 0x21, 0xc1, 0x13, 0x5e, + 0xad, 0xa3, 0x50, 0x99, 0xa7, 0xcf, 0x45, 0x69, 0xcd, 0x38, 0xd0, 0xe6, + 0x49, 0xb9, 0xae, 0xac, 0x19, 0x07, 0xda, 0xfc, 0xe1, 0x2b, 0xcb, 0x56, + 0x63, 0x63, 0x56, 0x03, 0xb4, 0x1f, 0xc3, 0x3e, 0x4d, 0xe4, 0xfe, 0xb4, + 0xe1, 0x21, 0x50, 0x89, 0x65, 0xda, 0x1d, 0x02, 0x91, 0x08, 0x10, 0x45, + 0x91, 0x6d, 0xe3, 0xb6, 0x59, 0xd0, 0x2a, 0x2b, 0x96, 0xc2, 0xa9, 0xc2, + 0x84, 0xab, 0x2b, 0xe0, 0x2c, 0x03, 0x9d, 0xd2, 0x41, 0xaa, 0x57, 0x9e, + 0x5a, 0x83, 0x63, 0xfd, 0x98, 0x44, 0xdc, 0xa6, 0x0f, 0xee, 0x4a, 0x48, + 0x22, 0x3b, 0x68, 0x66, 0x25, 0xa6, 0x79, 0xab, 0x53, 0x53, 0x55, 0x4e, + 0x95, 0x88, 0xaa, 0x20, 0x66, 0x13, 0x9a, 0xaa, 0x61, 0x32, 0xb5, 0x0e, + 0x80, 0x02, 0xab, 0x81, 0xca, 0x1b, 0xcd, 0x0f, 0x40, 0xd9, 0xcc, 0x5b, + 0x29, 0x20, 0x7b, 0x6b, 0x33, 0x3a, 0xa0, 0x56, 0x01, 0x8e, 0x0a, 0x88, + 0xed, 0xbf, 0xa3, 0x81, 0xd3, 0x81, 0xe0, 0x83, 0x4a, 0x6b, 0xe1, 0x74, + 0xf5, 0xd6, 0xc2, 0xeb, 0xaa, 0xae, 0x85, 0xdb, 0xd1, 0x9e, 0xfe, 0xab, + 0x9b, 0x47, 0xb7, 0xee, 0x47, 0xa8, 0x72, 0x52, 0xf9, 0xee, 0xfe, 0xe3, + 0x6a, 0xef,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c, 0xe7, 0x5f, 0xe5, 0x92, 0x4b, 0x42, 0xb8, 0xc7, 0x5f, + 0x4d, 0xff, 0x75, 0xce, 0xad, 0x8b, 0x97, 0xea, 0x93, 0xca, 0xa2, 0xfb, + 0x85, 0x50, 0x39, 0xad, 0x0e, 0xe1, 0xff, 0xbf, 0x14, 0x56, 0xb5, 0xd7, + 0x5c, 0x05, 0x77, 0xee, 0x82, 0x9d, 0xbb, 0xf9, 0x11, 0x55, 0x3f, 0xe0, + 0x02, 0xdf, 0xd6, 0x31, 0xde, 0x16, 0x46, 0xad, 0x37, 0x47, 0x21, 0x18, + 0x03, 0x6e, 0x77, 0x68, 0x90, 0x23, 0xc6, 0xff, 0x44, 0xe2, 0x4e, 0xb0, + 0x9d, 0x0f, 0x34, 0xf3, 0xf8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, + 0x97, 0x04, 0xc9, 0x61, 0x11, 0x00, 0x00, }, "sqlc/tmpl/fields.tmpl", ) @@ -118,53 +128,58 @@ func sqlc_tmpl_fields_tmpl() ([]byte, error) { func sqlc_tmpl_schema_tmpl() ([]byte, error) { return bindata_read([]byte{ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0x9c, 0x54, - 0x51, 0x8f, 0x9a, 0x4c, 0x14, 0x7d, 0xe7, 0x57, 0xdc, 0x90, 0xcd, 0x17, - 0xf8, 0x62, 0xf1, 0xdd, 0xc4, 0x07, 0x9a, 0x65, 0x77, 0x49, 0x2c, 0x36, - 0x32, 0xae, 0x69, 0x9a, 0xc6, 0x8c, 0xec, 0xe0, 0xd2, 0x22, 0x50, 0x66, - 0xdc, 0xd6, 0x18, 0xff, 0x7b, 0xef, 0xcc, 0x80, 0x62, 0x1d, 0x57, 0x52, - 0x63, 0x0c, 0xce, 0x9c, 0x7b, 0xee, 0x39, 0x67, 0xee, 0x30, 0x1c, 0x02, - 0x79, 0x0a, 0x63, 0x78, 0x08, 0x27, 0x01, 0x2c, 0xfc, 0x18, 0xfc, 0x39, - 0x99, 0x3e, 0x06, 0x51, 0x30, 0xf3, 0x49, 0x70, 0x0f, 0x1f, 0xc0, 0x8f, - 0xbe, 0x40, 0x70, 0x1f, 0x92, 0x18, 0xc8, 0x54, 0x43, 0x17, 0xe1, 0x64, - 0x02, 0x1f, 0x03, 0x98, 0x4c, 0x63, 0x02, 0x8b, 0xa7, 0x20, 0x82, 0x90, - 0x00, 0xae, 0xcf, 0x82, 0x63, 0x9d, 0x85, 0xb4, 0x3e, 0x81, 0xfd, 0x1e, - 0xbc, 0xcf, 0x75, 0xf9, 0xc6, 0x0a, 0x5a, 0x24, 0xcc, 0x23, 0xd9, 0x86, - 0x71, 0x41, 0x37, 0x15, 0x1c, 0x0e, 0x30, 0x8f, 0xc3, 0xe8, 0x11, 0xf8, - 0xcf, 0x3c, 0x81, 0xe7, 0x60, 0x16, 0x87, 0xd3, 0xe8, 0x6f, 0xf8, 0x33, - 0xab, 0x79, 0x56, 0x16, 0x08, 0xb6, 0x2c, 0xdc, 0xba, 0x13, 0xbb, 0x8a, - 0x71, 0x18, 0x8d, 0xc1, 0x23, 0xea, 0x49, 0xae, 0x57, 0x34, 0xf9, 0x41, - 0xd7, 0x4c, 0x97, 0x36, 0xcf, 0x72, 0x3d, 0xdb, 0x54, 0x65, 0x2d, 0xc0, - 0xb1, 0x00, 0xec, 0x75, 0x26, 0x5e, 0xb7, 0x2b, 0x2f, 0x29, 0x37, 0x43, - 0xfe, 0xba, 0x15, 0xec, 0xfb, 0x50, 0x76, 0x55, 0x3f, 0xb6, 0xdc, 0xe7, - 0xa2, 0xce, 0x8a, 0x35, 0xb7, 0x2d, 0x57, 0xf5, 0xa9, 0x69, 0x81, 0x24, - 0x77, 0xcb, 0x01, 0x76, 0xd4, 0xdd, 0xe8, 0x2a, 0x6f, 0xda, 0x49, 0x09, - 0xb2, 0x97, 0x28, 0x27, 0xe5, 0x2f, 0x56, 0x23, 0xc2, 0x8b, 0xe8,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x34, 0xba, 0xd0, + 0x51, 0xa1, 0x9c, 0x91, 0x5c, 0x3d, 0xcf, 0x98, 0x22, 0xa9, 0x06, 0xad, + 0xd3, 0x56, 0x0e, 0x97, 0xc8, 0xb5, 0xd0, 0xc2, 0x2b, 0xfe, 0xe0, 0x8a, + 0x55, 0x58, 0x3e, 0xca, 0xb8, 0x24, 0x60, 0x2c, 0x75, 0x44, 0xe1, 0xc0, + 0x18, 0xcf, 0x41, 0x62, 0x0e, 0xc2, 0x0a, 0x6f, 0x12, 0x9c, 0x6e, 0x04, + 0x0c, 0x48, 0x88, 0x87, 0xb2, 0xe4, 0x10, 0xf1, 0x09, 0x82, 0x29, 0xb6, + 0x78, 0x12, 0xb1, 0x48, 0x80, 0x2d, 0x89, 0x1e, 0x59, 0x8f, 0xf3, 0x8d, + 0xec, 0x45, 0x69, 0x82, 0x08, 0x48, 0x53, 0x1a, 0xd3, 0x14, 0xd7, 0x79, + 0x04, 0x06, 0x85, 0x8f, 0x4a, 0x5d, 0x26, 0xb8, 0x24, 0xc0, 0x29, 0x8e, + 0x28, 0x77, 0x61, 0x98, 0x70, 0x98, 0xd0, 0x22, 0x13, 0x61, 0xc5, 0x92, + 0x45, 0x98, 0xaa, 0x30, 0xad, 0xab, 0xbc, 0xdd, 0x9a, 0xc2, 0xcb, 0x3f, + 0x94, 0x10, 0xc2, 0xe6, 0xb7, 0x9a, 0xf9, 0x88, 0x13, 0xbc, 0x31, 0xa8, + 0xd5, 0xd1, 0xcd, 0xc4, 0x3c, 0x86, 0x58, 0xba, 0x39, 0x85, 0xcf, 0x26, + 0x06, 0x6a, 0xd9, 0x4c, 0xc9, 0x71, 0xf2, 0xdd, 0xa7, 0xff, 0xa0, 0xec, + 0xe7, 0x05, 0x53, 0x26, 0x37, 0x32, 0xbb, 0x05, 0x50, 0x4b, 0xb9, 0x31, + 0xeb, 0x7a, 0x8e, 0xf3, 0x6b, 0x27, 0xb8, 0x40, 0x7c, 0xab, 0x99, 0xe4, + 0x8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, 0x11, 0xd4, 0x59, 0xf4, 0x19, 0x1b, 0xed, 0x5f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xd4, 0xa6, 0xda, 0x3b, 0xc5, 0x07, 0x00, 0x00, }, "sqlc/tmpl/schema.tmpl", ) @@ -195,7 +210,6 @@ var _bindata = map[string]func() ([]byte, error){ "sqlc/tmpl/fields.tmpl": sqlc_tmpl_fields_tmpl, "sqlc/tmpl/schema.tmpl": sqlc_tmpl_schema_tmpl, } - // AssetDir returns the file names below a certain // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the @@ -229,15 +243,16 @@ func AssetDir(name string) ([]string, error) { } type _bintree_t struct { - Func func() ([]byte, error) + Func func() ([]byte, error) Children map[string]*_bintree_t } - var _bintree = &_bintree_t{nil, map[string]*_bintree_t{ "sqlc": &_bintree_t{nil, map[string]*_bintree_t{ "tmpl": &_bintree_t{nil, map[string]*_bintree_t{ - "fields.tmpl": &_bintree_t{sqlc_tmpl_fields_tmpl, map[string]*_bintree_t{}}, - "schema.tmpl": &_bintree_t{sqlc_tmpl_schema_tmpl, map[string]*_bintree_t{}}, + "fields.tmpl": &_bintree_t{sqlc_tmpl_fields_tmpl, map[string]*_bintree_t{ + }}, + "schema.tmpl": &_bintree_t{sqlc_tmpl_schema_tmpl, map[string]*_bintree_t{ + }}, }}, }}, }} diff --git a/sqlc/sqlc.go b/sqlc/sqlc.go index eb235db..aaeb130 100644 --- a/sqlc/sqlc.go +++ b/sqlc/sqlc.go @@ -4,6 +4,8 @@ import ( "bytes" "database/sql" "io" + "reflect" + "strings" ) type PredicateType int @@ -54,6 +56,7 @@ type Field interface { Aliasable Functional Name() string + Type() reflect.Type As(string) Field Function() FieldFunction } @@ -201,3 +204,13 @@ func exec(d Dialect, r Renderable, db *sql.DB) (sql.Result, error) { args := r.Render(d, &buf) return db.Exec(buf.String(), args...) } + +func Qualified(parts ...string) string { + tmp := []string{} + for _, part := range parts { + if part != "" { + tmp = append(tmp, part) + } + } + return strings.Join(tmp, ".") +} diff --git a/sqlc/tmpl/fields.tmpl b/sqlc/tmpl/fields.tmpl index 60afb29..4b2b6d9 100644 --- a/sqlc/tmpl/fields.tmpl +++ b/sqlc/tmpl/fields.tmpl @@ -6,30 +6,41 @@ package sqlc import ( - "time" + "reflect" + "time" +) + +var ( + typeString = reflect.TypeOf("") + typeBool = reflect.TypeOf(false) + typeInt = reflect.TypeOf(int(0)) + typeInt64 = reflect.TypeOf(int64(0)) + typeFloat32 = reflect.TypeOf(float32(0.)) + typeFloat64 = reflect.TypeOf(float64(0.)) + typeTime = reflect.TypeOf(time.Unix(0, 0)) ) type InsertSetStep interface { - {{ range $_, $t := .types }} - Set{{ $t.Prefix }}({{ $t.Prefix }}Field, {{ $t.Literal }}) InsertSetMoreStep - {{ end }} + {{ range $_, $t := .types }} + Set{{ $t.Prefix }}({{ $t.Prefix }}Field, {{ $t.Literal }}) InsertSetMoreStep + {{ end }} } type UpdateSetStep interface { - {{ range $_, $t := .types }} - Set{{ $t.Prefix }}({{ $t.Prefix }}Field, {{ $t.Literal }}) UpdateSetMoreStep - {{ end }} + {{ range $_, $t := .types }} + Set{{ $t.Prefix }}({{ $t.Prefix }}Field, {{ $t.Literal }}) UpdateSetMoreStep + {{ end }} } {{ range $_, $t := .types }} func (i *insert) Set{{ $t.Prefix }}(f {{ $t.Prefix }}Field, v {{ $t.Literal }}) InsertSetMoreStep { - return i.set(f,v) + return i.set(f,v) } {{ end }} {{ range $_, $t := .types }} func (u *update) Set{{ $t.Prefix }}(f {{ $t.Prefix }}Field, v {{ $t.Literal }}) UpdateSetMoreStep { - return u.set(f,v) + return u.set(f,v) } {{ end }} @@ -37,22 +48,22 @@ func (u *update) Set{{ $t.Prefix }}(f {{ $t.Prefix }}Field, v {{ $t.Literal }}) type Reflectable interface { {{ range $_, $t := .types }} - {{ $t.Prefix }}Field(name string) {{ $t.Prefix }}Field + {{ $t.Prefix }}Field(name string) {{ $t.Prefix }}Field {{ end }} } type Functional interface { {{ range $_, $f := $funcs }} - {{ $f.Name }}({{ signifier $f }}) Field + {{ $f.Name }}({{ signifier $f }}) Field {{ end }} } {{ range $_, $t := .types }} func (s *selection) {{ $t.Prefix }}Field(name string) {{ $t.Prefix }}Field { - return &{{ toLower $t.Prefix }}Field{name: name} + return &{{ toLower $t.Prefix }}Field{name: name} } func (t table) {{ $t.Prefix }}Field(name string) {{ $t.Prefix }}Field { - return &{{ toLower $t.Prefix }}Field{name: name, selection: t} + return &{{ toLower $t.Prefix }}Field{name: name, selection: t} } {{ end }} @@ -61,87 +72,91 @@ func (t table) {{ $t.Prefix }}Field(name string) {{ $t.Prefix }}Field { {{ range $_, $t := .types }} type {{ toLower $t.Prefix }}Field struct { - name string - selection Selectable - alias string - fun FieldFunction + name string + selection Selectable + alias string + fun FieldFunction } type {{ $t.Prefix }}Field interface { - TableField - {{ range $_, $p := $preds }} - {{ $p.FieldFunction }}(value {{ $t.Literal }}) Condition - {{ $p.JoinFunction }}(value {{ $t.Prefix }}Field) JoinCondition - {{ end }} + TableField + {{ range $_, $p := $preds }} + {{ $p.FieldFunction }}(value {{ $t.Literal }}) Condition + {{ $p.JoinFunction }}(value {{ $t.Prefix }}Field) JoinCondition + {{ end }} } func (c *{{ toLower $t.Prefix }}Field) Function() FieldFunction { - return FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - } + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } } func (c *{{ toLower $t.Prefix }}Field) fct(fun, expr string, args ...interface{}) Field { - if &c.fun == nil { - return &{{ toLower $t.Prefix }}Field{ - name: c.name, - selection: c.selection, - fun: FieldFunction{Name:fun, Expr:expr, Args: args}, - } - } else { - return &{{ toLower $t.Prefix }}Field{ - name: c.name, - selection: c.selection, - fun: FieldFunction{ - Name: fun, - Expr: expr, - Args: args, - Child: &FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - }, - } - } + if &c.fun == nil { + return &{{ toLower $t.Prefix }}Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &{{ toLower $t.Prefix }}Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } } func (c *{{ toLower $t.Prefix }}Field) As(alias string) Field { - return &{{ toLower $t.Prefix }}Field{ - name: c.name, - selection: c.selection, - alias: alias, - fun: FieldFunction{ - Name: c.fun.Name, - Expr: c.fun.Expr, - Args: c.fun.Args, - Child: c.fun.Child, - }, - } + return &{{ toLower $t.Prefix }}Field{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } } func (c *{{ toLower $t.Prefix }}Field) Alias() string { - return c.alias + return c.alias } func (c *{{ toLower $t.Prefix }}Field) MaybeAlias() string { - if c.alias == "" { - return c.name - } else { - return c.alias - } + if c.alias == "" { + return c.name + } else { + return c.alias + } } func (c *{{ toLower $t.Prefix }}Field) Name() string { - return c.name + return c.name +} + +func (c *{{ toLower $t.Prefix }}Field) Type() reflect.Type { + return type{{ $t.Prefix }} } func (c *{{ toLower $t.Prefix }}Field) Parent() Selectable { - return c.selection + return c.selection } // -- @@ -149,11 +164,11 @@ func (c *{{ toLower $t.Prefix }}Field) Parent() Selectable { {{ range $_, $p := $preds }} func (c *{{ toLower $t.Prefix }}Field) {{ $p.FieldFunction }}(pred {{ $t.Literal }}) Condition { - return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: {{ $p.Predicate }}} + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: {{ $p.Predicate }}} } func (c *{{ toLower $t.Prefix }}Field) {{ $p.JoinFunction }}(pred {{ $t.Prefix }}Field) JoinCondition { - return JoinCondition{Lhs: c, Rhs: pred, Predicate: {{ $p.Predicate }}} + return JoinCondition{Lhs: c, Rhs: pred, Predicate: {{ $p.Predicate }}} } {{ end }} @@ -161,14 +176,14 @@ func (c *{{ toLower $t.Prefix }}Field) {{ $p.JoinFunction }}(pred {{ $t.Prefix } // -- func {{ $t.Prefix }}(s Selectable, name string) {{ $t.Prefix }}Field { - return &{{ toLower $t.Prefix }}Field{name: name, selection: s} + return &{{ toLower $t.Prefix }}Field{name: name, selection: s} } ////// {{ range $_, $f := $funcs }} -func (c *{{ toLower $t.Prefix }}Field) {{ $f.Name }}({{ signifier $f }}) Field { - return c.fct("{{ $f.Name }}", "{{ $f.Expr }}"{{ injectifier $f }}) +func (c *{{ toLower $t.Prefix }}Field) {{ $f.Name }}({{ signifier $f }}) Field { + return c.fct("{{ $f.Name }}", "{{ $f.Expr }}"{{ injectifier $f }}) } {{ end }} diff --git a/sqlc/tmpl/schema.tmpl b/sqlc/tmpl/schema.tmpl index 9f64257..28f74b5 100644 --- a/sqlc/tmpl/schema.tmpl +++ b/sqlc/tmpl/schema.tmpl @@ -10,6 +10,8 @@ import ( "strings" ) +const Schema = "{{ .Schema }}" + {{ range $_, $t := .Tables }} type {{ toLower $t.Name }} struct { @@ -21,8 +23,12 @@ type {{ toLower $t.Name }} struct { func (t *{{ toLower $t.Name }}) IsSelectable() {} +func (t *{{ toLower $t.Name }}) Schema() string { + return Schema +} + func (t *{{ toLower $t.Name }}) Name() string { - return "{{ toLower $t.Name }}" + return sqlc.Qualified(t.Schema(), "{{ toLower $t.Name }}") } func (t *{{ toLower $t.Name }}) As(a string) sqlc.Selectable { @@ -76,5 +82,9 @@ var {{ toUpper $t.Name }} = &{{ toLower $t.Name }} { } - -{{ end }} \ No newline at end of file +{{ end }} +var TableLikes = []sqlc.TableLike{ +{{ range $_, $t := .Tables }} + {{ toUpper $t.Name }}, +{{ end }} +} From 4c86a00ede4aa024352df8cb5658e7f314729d75 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Thu, 8 Jan 2015 13:56:35 -0500 Subject: [PATCH 04/17] fix null time support --- meta/types.go | 8 + sqlc/fields.go | 1575 ++++++++++++++++++++++++++++++++++++++++- sqlc/generator.go | 18 +- sqlc/schema.go | 191 ++--- sqlc/sqlc.go | 21 + sqlc/tmpl/fields.tmpl | 14 +- 6 files changed, 1725 insertions(+), 102 deletions(-) diff --git a/meta/types.go b/meta/types.go index 1d4bcdc..18895a4 100644 --- a/meta/types.go +++ b/meta/types.go @@ -18,6 +18,14 @@ var Types = []TypeInfo{ TypeInfo{Prefix: "Float32", Literal: "float32"}, TypeInfo{Prefix: "Float64", Literal: "float64"}, TypeInfo{Prefix: "Time", Literal: "time.Time"}, + + TypeInfo{Prefix: "NullString", Literal: "sql.NullString"}, + TypeInfo{Prefix: "NullBool", Literal: "sql.NullBool"}, + TypeInfo{Prefix: "NullInt", Literal: "sql.NullInt64"}, // TODO(shutej): test + TypeInfo{Prefix: "NullInt64", Literal: "sql.NullInt64"}, + TypeInfo{Prefix: "NullFloat32", Literal: "sql.NullFloat64"}, // TODO(shutej): test + TypeInfo{Prefix: "NullFloat64", Literal: "sql.NullFloat64"}, + TypeInfo{Prefix: "NullTime", Literal: "NullableTime"}, } type FunctionInfo struct { diff --git a/sqlc/fields.go b/sqlc/fields.go index 444b80c..4b5796b 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -6,17 +6,25 @@ package sqlc import ( + "database/sql" "reflect" "time" ) var ( - typeString = reflect.TypeOf("") typeBool = reflect.TypeOf(false) - typeInt = reflect.TypeOf(int(0)) - typeInt64 = reflect.TypeOf(int64(0)) typeFloat32 = reflect.TypeOf(float32(0.)) typeFloat64 = reflect.TypeOf(float64(0.)) + typeInt = reflect.TypeOf(int(0)) + typeInt64 = reflect.TypeOf(int64(0)) + typeNullBool = reflect.TypeOf(sql.NullBool{}) + typeNullFloat32 = reflect.TypeOf(sql.NullFloat64{}) + typeNullFloat64 = reflect.TypeOf(sql.NullFloat64{}) + typeNullInt = reflect.TypeOf(sql.NullInt64{}) + typeNullInt64 = reflect.TypeOf(sql.NullInt64{}) + typeNullString = reflect.TypeOf(sql.NullString{}) + typeNullTime = reflect.TypeOf(NullableTime{}) + typeString = reflect.TypeOf("") typeTime = reflect.TypeOf(time.Unix(0, 0)) ) @@ -36,6 +44,20 @@ type InsertSetStep interface { SetTime(TimeField, time.Time) InsertSetMoreStep + SetNullString(NullStringField, sql.NullString) InsertSetMoreStep + + SetNullBool(NullBoolField, sql.NullBool) InsertSetMoreStep + + SetNullInt(NullIntField, sql.NullInt64) InsertSetMoreStep + + SetNullInt64(NullInt64Field, sql.NullInt64) InsertSetMoreStep + + SetNullFloat32(NullFloat32Field, sql.NullFloat64) InsertSetMoreStep + + SetNullFloat64(NullFloat64Field, sql.NullFloat64) InsertSetMoreStep + + SetNullTime(NullTimeField, NullableTime) InsertSetMoreStep + } type UpdateSetStep interface { @@ -54,6 +76,20 @@ type UpdateSetStep interface { SetTime(TimeField, time.Time) UpdateSetMoreStep + SetNullString(NullStringField, sql.NullString) UpdateSetMoreStep + + SetNullBool(NullBoolField, sql.NullBool) UpdateSetMoreStep + + SetNullInt(NullIntField, sql.NullInt64) UpdateSetMoreStep + + SetNullInt64(NullInt64Field, sql.NullInt64) UpdateSetMoreStep + + SetNullFloat32(NullFloat32Field, sql.NullFloat64) UpdateSetMoreStep + + SetNullFloat64(NullFloat64Field, sql.NullFloat64) UpdateSetMoreStep + + SetNullTime(NullTimeField, NullableTime) UpdateSetMoreStep + } @@ -85,6 +121,34 @@ func (i *insert) SetTime(f TimeField, v time.Time) InsertSetMoreStep { return i.set(f,v) } +func (i *insert) SetNullString(f NullStringField, v sql.NullString) InsertSetMoreStep { + return i.set(f,v) +} + +func (i *insert) SetNullBool(f NullBoolField, v sql.NullBool) InsertSetMoreStep { + return i.set(f,v) +} + +func (i *insert) SetNullInt(f NullIntField, v sql.NullInt64) InsertSetMoreStep { + return i.set(f,v) +} + +func (i *insert) SetNullInt64(f NullInt64Field, v sql.NullInt64) InsertSetMoreStep { + return i.set(f,v) +} + +func (i *insert) SetNullFloat32(f NullFloat32Field, v sql.NullFloat64) InsertSetMoreStep { + return i.set(f,v) +} + +func (i *insert) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) InsertSetMoreStep { + return i.set(f,v) +} + +func (i *insert) SetNullTime(f NullTimeField, v NullableTime) InsertSetMoreStep { + return i.set(f,v) +} + func (u *update) SetString(f StringField, v string) UpdateSetMoreStep { @@ -115,6 +179,34 @@ func (u *update) SetTime(f TimeField, v time.Time) UpdateSetMoreStep { return u.set(f,v) } +func (u *update) SetNullString(f NullStringField, v sql.NullString) UpdateSetMoreStep { + return u.set(f,v) +} + +func (u *update) SetNullBool(f NullBoolField, v sql.NullBool) UpdateSetMoreStep { + return u.set(f,v) +} + +func (u *update) SetNullInt(f NullIntField, v sql.NullInt64) UpdateSetMoreStep { + return u.set(f,v) +} + +func (u *update) SetNullInt64(f NullInt64Field, v sql.NullInt64) UpdateSetMoreStep { + return u.set(f,v) +} + +func (u *update) SetNullFloat32(f NullFloat32Field, v sql.NullFloat64) UpdateSetMoreStep { + return u.set(f,v) +} + +func (u *update) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) UpdateSetMoreStep { + return u.set(f,v) +} + +func (u *update) SetNullTime(f NullTimeField, v NullableTime) UpdateSetMoreStep { + return u.set(f,v) +} + ///// @@ -134,6 +226,20 @@ type Reflectable interface { TimeField(name string) TimeField + NullStringField(name string) NullStringField + + NullBoolField(name string) NullBoolField + + NullIntField(name string) NullIntField + + NullInt64Field(name string) NullInt64Field + + NullFloat32Field(name string) NullFloat32Field + + NullFloat64Field(name string) NullFloat64Field + + NullTimeField(name string) NullTimeField + } type Functional interface { @@ -208,6 +314,55 @@ func (t table) TimeField(name string) TimeField { return &timeField{name: name, selection: t} } +func (s *selection) NullStringField(name string) NullStringField { + return &nullstringField{name: name} +} +func (t table) NullStringField(name string) NullStringField { + return &nullstringField{name: name, selection: t} +} + +func (s *selection) NullBoolField(name string) NullBoolField { + return &nullboolField{name: name} +} +func (t table) NullBoolField(name string) NullBoolField { + return &nullboolField{name: name, selection: t} +} + +func (s *selection) NullIntField(name string) NullIntField { + return &nullintField{name: name} +} +func (t table) NullIntField(name string) NullIntField { + return &nullintField{name: name, selection: t} +} + +func (s *selection) NullInt64Field(name string) NullInt64Field { + return &nullint64Field{name: name} +} +func (t table) NullInt64Field(name string) NullInt64Field { + return &nullint64Field{name: name, selection: t} +} + +func (s *selection) NullFloat32Field(name string) NullFloat32Field { + return &nullfloat32Field{name: name} +} +func (t table) NullFloat32Field(name string) NullFloat32Field { + return &nullfloat32Field{name: name, selection: t} +} + +func (s *selection) NullFloat64Field(name string) NullFloat64Field { + return &nullfloat64Field{name: name} +} +func (t table) NullFloat64Field(name string) NullFloat64Field { + return &nullfloat64Field{name: name, selection: t} +} + +func (s *selection) NullTimeField(name string) NullTimeField { + return &nulltimeField{name: name} +} +func (t table) NullTimeField(name string) NullTimeField { + return &nulltimeField{name: name, selection: t} +} + ///// @@ -1626,3 +1781,1417 @@ func (c *timeField) Hex() Field { + +type nullstringField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type NullStringField interface { + TableField + + Eq(value sql.NullString) Condition + IsEq(value NullStringField) JoinCondition + + Gt(value sql.NullString) Condition + IsGt(value NullStringField) JoinCondition + + Ge(value sql.NullString) Condition + IsGe(value NullStringField) JoinCondition + + Lt(value sql.NullString) Condition + IsLt(value NullStringField) JoinCondition + + Le(value sql.NullString) Condition + IsLe(value NullStringField) JoinCondition + +} + +func (c *nullstringField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *nullstringField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &nullstringField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &nullstringField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *nullstringField) As(alias string) Field { + return &nullstringField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *nullstringField) Alias() string { + return c.alias +} + +func (c *nullstringField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *nullstringField) Name() string { + return c.name +} + +func (c *nullstringField) Type() reflect.Type { + return typeNullString +} + +func (c *nullstringField) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *nullstringField) Eq(pred sql.NullString) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *nullstringField) IsEq(pred NullStringField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *nullstringField) Gt(pred sql.NullString) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *nullstringField) IsGt(pred NullStringField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *nullstringField) Ge(pred sql.NullString) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *nullstringField) IsGe(pred NullStringField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *nullstringField) Lt(pred sql.NullString) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *nullstringField) IsLt(pred NullStringField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *nullstringField) Le(pred sql.NullString) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *nullstringField) IsLe(pred NullStringField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func NullString(s Selectable, name string) NullStringField { + return &nullstringField{name: name, selection: s} +} + +////// + + +func (c *nullstringField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *nullstringField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *nullstringField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *nullstringField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *nullstringField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *nullstringField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *nullstringField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *nullstringField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *nullstringField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + + + + +type nullboolField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type NullBoolField interface { + TableField + + Eq(value sql.NullBool) Condition + IsEq(value NullBoolField) JoinCondition + + Gt(value sql.NullBool) Condition + IsGt(value NullBoolField) JoinCondition + + Ge(value sql.NullBool) Condition + IsGe(value NullBoolField) JoinCondition + + Lt(value sql.NullBool) Condition + IsLt(value NullBoolField) JoinCondition + + Le(value sql.NullBool) Condition + IsLe(value NullBoolField) JoinCondition + +} + +func (c *nullboolField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *nullboolField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &nullboolField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &nullboolField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *nullboolField) As(alias string) Field { + return &nullboolField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *nullboolField) Alias() string { + return c.alias +} + +func (c *nullboolField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *nullboolField) Name() string { + return c.name +} + +func (c *nullboolField) Type() reflect.Type { + return typeNullBool +} + +func (c *nullboolField) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *nullboolField) Eq(pred sql.NullBool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *nullboolField) IsEq(pred NullBoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *nullboolField) Gt(pred sql.NullBool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *nullboolField) IsGt(pred NullBoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *nullboolField) Ge(pred sql.NullBool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *nullboolField) IsGe(pred NullBoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *nullboolField) Lt(pred sql.NullBool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *nullboolField) IsLt(pred NullBoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *nullboolField) Le(pred sql.NullBool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *nullboolField) IsLe(pred NullBoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func NullBool(s Selectable, name string) NullBoolField { + return &nullboolField{name: name, selection: s} +} + +////// + + +func (c *nullboolField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *nullboolField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *nullboolField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *nullboolField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *nullboolField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *nullboolField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *nullboolField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *nullboolField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *nullboolField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + + + + +type nullintField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type NullIntField interface { + TableField + + Eq(value sql.NullInt64) Condition + IsEq(value NullIntField) JoinCondition + + Gt(value sql.NullInt64) Condition + IsGt(value NullIntField) JoinCondition + + Ge(value sql.NullInt64) Condition + IsGe(value NullIntField) JoinCondition + + Lt(value sql.NullInt64) Condition + IsLt(value NullIntField) JoinCondition + + Le(value sql.NullInt64) Condition + IsLe(value NullIntField) JoinCondition + +} + +func (c *nullintField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *nullintField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &nullintField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &nullintField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *nullintField) As(alias string) Field { + return &nullintField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *nullintField) Alias() string { + return c.alias +} + +func (c *nullintField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *nullintField) Name() string { + return c.name +} + +func (c *nullintField) Type() reflect.Type { + return typeNullInt +} + +func (c *nullintField) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *nullintField) Eq(pred sql.NullInt64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *nullintField) IsEq(pred NullIntField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *nullintField) Gt(pred sql.NullInt64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *nullintField) IsGt(pred NullIntField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *nullintField) Ge(pred sql.NullInt64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *nullintField) IsGe(pred NullIntField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *nullintField) Lt(pred sql.NullInt64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *nullintField) IsLt(pred NullIntField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *nullintField) Le(pred sql.NullInt64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *nullintField) IsLe(pred NullIntField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func NullInt(s Selectable, name string) NullIntField { + return &nullintField{name: name, selection: s} +} + +////// + + +func (c *nullintField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *nullintField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *nullintField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *nullintField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *nullintField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *nullintField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *nullintField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *nullintField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *nullintField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + + + + +type nullint64Field struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type NullInt64Field interface { + TableField + + Eq(value sql.NullInt64) Condition + IsEq(value NullInt64Field) JoinCondition + + Gt(value sql.NullInt64) Condition + IsGt(value NullInt64Field) JoinCondition + + Ge(value sql.NullInt64) Condition + IsGe(value NullInt64Field) JoinCondition + + Lt(value sql.NullInt64) Condition + IsLt(value NullInt64Field) JoinCondition + + Le(value sql.NullInt64) Condition + IsLe(value NullInt64Field) JoinCondition + +} + +func (c *nullint64Field) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *nullint64Field) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &nullint64Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &nullint64Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *nullint64Field) As(alias string) Field { + return &nullint64Field{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *nullint64Field) Alias() string { + return c.alias +} + +func (c *nullint64Field) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *nullint64Field) Name() string { + return c.name +} + +func (c *nullint64Field) Type() reflect.Type { + return typeNullInt64 +} + +func (c *nullint64Field) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *nullint64Field) Eq(pred sql.NullInt64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *nullint64Field) IsEq(pred NullInt64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *nullint64Field) Gt(pred sql.NullInt64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *nullint64Field) IsGt(pred NullInt64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *nullint64Field) Ge(pred sql.NullInt64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *nullint64Field) IsGe(pred NullInt64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *nullint64Field) Lt(pred sql.NullInt64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *nullint64Field) IsLt(pred NullInt64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *nullint64Field) Le(pred sql.NullInt64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *nullint64Field) IsLe(pred NullInt64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func NullInt64(s Selectable, name string) NullInt64Field { + return &nullint64Field{name: name, selection: s} +} + +////// + + +func (c *nullint64Field) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *nullint64Field) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *nullint64Field) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *nullint64Field) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *nullint64Field) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *nullint64Field) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *nullint64Field) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *nullint64Field) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *nullint64Field) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + + + + +type nullfloat32Field struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type NullFloat32Field interface { + TableField + + Eq(value sql.NullFloat64) Condition + IsEq(value NullFloat32Field) JoinCondition + + Gt(value sql.NullFloat64) Condition + IsGt(value NullFloat32Field) JoinCondition + + Ge(value sql.NullFloat64) Condition + IsGe(value NullFloat32Field) JoinCondition + + Lt(value sql.NullFloat64) Condition + IsLt(value NullFloat32Field) JoinCondition + + Le(value sql.NullFloat64) Condition + IsLe(value NullFloat32Field) JoinCondition + +} + +func (c *nullfloat32Field) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *nullfloat32Field) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &nullfloat32Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &nullfloat32Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *nullfloat32Field) As(alias string) Field { + return &nullfloat32Field{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *nullfloat32Field) Alias() string { + return c.alias +} + +func (c *nullfloat32Field) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *nullfloat32Field) Name() string { + return c.name +} + +func (c *nullfloat32Field) Type() reflect.Type { + return typeNullFloat32 +} + +func (c *nullfloat32Field) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *nullfloat32Field) Eq(pred sql.NullFloat64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *nullfloat32Field) IsEq(pred NullFloat32Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *nullfloat32Field) Gt(pred sql.NullFloat64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *nullfloat32Field) IsGt(pred NullFloat32Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *nullfloat32Field) Ge(pred sql.NullFloat64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *nullfloat32Field) IsGe(pred NullFloat32Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *nullfloat32Field) Lt(pred sql.NullFloat64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *nullfloat32Field) IsLt(pred NullFloat32Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *nullfloat32Field) Le(pred sql.NullFloat64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *nullfloat32Field) IsLe(pred NullFloat32Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func NullFloat32(s Selectable, name string) NullFloat32Field { + return &nullfloat32Field{name: name, selection: s} +} + +////// + + +func (c *nullfloat32Field) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *nullfloat32Field) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *nullfloat32Field) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *nullfloat32Field) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *nullfloat32Field) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *nullfloat32Field) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *nullfloat32Field) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *nullfloat32Field) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *nullfloat32Field) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + + + + +type nullfloat64Field struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type NullFloat64Field interface { + TableField + + Eq(value sql.NullFloat64) Condition + IsEq(value NullFloat64Field) JoinCondition + + Gt(value sql.NullFloat64) Condition + IsGt(value NullFloat64Field) JoinCondition + + Ge(value sql.NullFloat64) Condition + IsGe(value NullFloat64Field) JoinCondition + + Lt(value sql.NullFloat64) Condition + IsLt(value NullFloat64Field) JoinCondition + + Le(value sql.NullFloat64) Condition + IsLe(value NullFloat64Field) JoinCondition + +} + +func (c *nullfloat64Field) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *nullfloat64Field) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &nullfloat64Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &nullfloat64Field{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *nullfloat64Field) As(alias string) Field { + return &nullfloat64Field{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *nullfloat64Field) Alias() string { + return c.alias +} + +func (c *nullfloat64Field) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *nullfloat64Field) Name() string { + return c.name +} + +func (c *nullfloat64Field) Type() reflect.Type { + return typeNullFloat64 +} + +func (c *nullfloat64Field) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *nullfloat64Field) Eq(pred sql.NullFloat64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *nullfloat64Field) IsEq(pred NullFloat64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *nullfloat64Field) Gt(pred sql.NullFloat64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *nullfloat64Field) IsGt(pred NullFloat64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *nullfloat64Field) Ge(pred sql.NullFloat64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *nullfloat64Field) IsGe(pred NullFloat64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *nullfloat64Field) Lt(pred sql.NullFloat64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *nullfloat64Field) IsLt(pred NullFloat64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *nullfloat64Field) Le(pred sql.NullFloat64) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *nullfloat64Field) IsLe(pred NullFloat64Field) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func NullFloat64(s Selectable, name string) NullFloat64Field { + return &nullfloat64Field{name: name, selection: s} +} + +////// + + +func (c *nullfloat64Field) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *nullfloat64Field) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *nullfloat64Field) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *nullfloat64Field) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *nullfloat64Field) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *nullfloat64Field) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *nullfloat64Field) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *nullfloat64Field) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *nullfloat64Field) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + + + + +type nulltimeField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type NullTimeField interface { + TableField + + Eq(value NullableTime) Condition + IsEq(value NullTimeField) JoinCondition + + Gt(value NullableTime) Condition + IsGt(value NullTimeField) JoinCondition + + Ge(value NullableTime) Condition + IsGe(value NullTimeField) JoinCondition + + Lt(value NullableTime) Condition + IsLt(value NullTimeField) JoinCondition + + Le(value NullableTime) Condition + IsLe(value NullTimeField) JoinCondition + +} + +func (c *nulltimeField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *nulltimeField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &nulltimeField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &nulltimeField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *nulltimeField) As(alias string) Field { + return &nulltimeField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *nulltimeField) Alias() string { + return c.alias +} + +func (c *nulltimeField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *nulltimeField) Name() string { + return c.name +} + +func (c *nulltimeField) Type() reflect.Type { + return typeNullTime +} + +func (c *nulltimeField) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *nulltimeField) Eq(pred NullableTime) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *nulltimeField) IsEq(pred NullTimeField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *nulltimeField) Gt(pred NullableTime) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *nulltimeField) IsGt(pred NullTimeField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *nulltimeField) Ge(pred NullableTime) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *nulltimeField) IsGe(pred NullTimeField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *nulltimeField) Lt(pred NullableTime) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *nulltimeField) IsLt(pred NullTimeField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *nulltimeField) Le(pred NullableTime) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *nulltimeField) IsLe(pred NullTimeField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func NullTime(s Selectable, name string) NullTimeField { + return &nulltimeField{name: name, selection: s} +} + +////// + + +func (c *nulltimeField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *nulltimeField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *nulltimeField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *nulltimeField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *nulltimeField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *nulltimeField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *nulltimeField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *nulltimeField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *nulltimeField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + + + diff --git a/sqlc/generator.go b/sqlc/generator.go index 80c603e..abfa9a1 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -167,14 +167,16 @@ func infoSchema(d Dialect, schema string, db *sql.DB) ([]TableMeta, error) { fields := make([]FieldMeta, 0) for rows.Next() { - var colName, colType sql.NullString - err = rows.Scan(&colName, &colType) + var colName, colType, colIsNullable sql.NullString + err = rows.Scan(&colName, &colType, &colIsNullable) if err != nil { return nil, err } var fieldType string + nullable := strings.ToUpper(colIsNullable.String) == "YES" + if int_64.MatchString(colType.String) { fieldType = "Int64" } else if integer.MatchString(colType.String) { @@ -191,6 +193,10 @@ func infoSchema(d Dialect, schema string, db *sql.DB) ([]TableMeta, error) { fieldType = "Bool" } + if nullable { + fieldType = "Null" + fieldType + } + field := FieldMeta{Name: colName.String, Type: fieldType} fields = append(fields, field) } @@ -232,6 +238,8 @@ func sqlite(db *sql.DB) ([]TableMeta, error) { return nil, err } + nullable := !notNull.Bool + var fieldType string if int_64.MatchString(colType.String) { @@ -250,6 +258,10 @@ func sqlite(db *sql.DB) ([]TableMeta, error) { fieldType = "Bool" } + if nullable { + fieldType = "Null" + fieldType + } + field := FieldMeta{Name: colName.String, Type: fieldType} //fmt.Printf("Field type: %s -> %s\n", fieldType, colType.String) fields = append(fields, field) @@ -275,7 +287,7 @@ const infoTablesTmpl = ` ` const infoColumnsTmpl = ` - SELECT column_name, UPPER(data_type) + SELECT column_name, UPPER(data_type), is_nullable FROM information_schema.columns WHERE table_schema = %s and table_name = %s; ` diff --git a/sqlc/schema.go b/sqlc/schema.go index 8d16dbf..73109c3 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -27,99 +27,104 @@ func bindata_read(data []byte, name string) ([]byte, error) { func sqlc_tmpl_fields_tmpl() ([]byte, error) { return bindata_read([]byte{ - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0xcc, 0x57, - 0xdf, 0x6f, 0xdb, 0x36, 0x10, 0x7e, 0xd7, 0x5f, 0x71, 0x30, 0x82, 0x40, - 0x0a, 0x14, 0x25, 0xd8, 0x8a, 0x3e, 0x18, 0xc8, 0x83, 0xd3, 0x3a, 0xab, - 0x07, 0xd7, 0x09, 0x62, 0x65, 0xc1, 0x9e, 0x06, 0x56, 0xa6, 0x5c, 0x6e, - 0x2a, 0xa5, 0x49, 0x74, 0x96, 0xc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x62, 0x8c, 0xa9, - 0xf5, 0xd0, 0xdd, 0xba, 0x0a, 0x25, 0x2c, 0x7d, 0x16, 0x5a, 0x61, 0x15, - 0x51, 0x0b, 0x0a, 0x15, 0xf6, 0x44, 0xb2, 0x0d, 0xed, 0x59, 0x7e, 0x1f, - 0x72, 0xbe, 0x62, 0x8a, 0x4f, 0xf3, 0xea, 0xaf, 0x39, 0xe3, 0x43, 0x6f, - 0xb6, 0x59, 0x06, 0x80, 0xbe, 0x9d, 0x08, 0x2f, 0x6a, 0xd5, 0x72, 0x48, - 0xe0, 0x6c, 0x5f, 0x5d, 0x03, 0xbb, 0x7e, 0xfc, 0xa0, 0x5d, 0x20, 0x57, - 0x08, 0xad, 0x09, 0xb4, 0x03, 0x2c, 0x54, 0xf7, 0x21, 0xc1, 0x13, 0x5e, - 0xad, 0xa3, 0x50, 0x99, 0xa7, 0xcf, 0x45, 0x69, 0xcd, 0x38, 0xd0, 0xe6, - 0x49, 0xb9, 0xae, 0xac, 0x19, 0x07, 0xda, 0xfc, 0xe1, 0x2b, 0xcb, 0x56, - 0x63, 0x63, 0x56, 0x03, 0xb4, 0x1f, 0xc3, 0x3e, 0x4d, 0xe4, 0xfe, 0xb4, - 0xe1, 0x21, 0x50, 0x89, 0x65, 0xda, 0x1d, 0x02, 0x91, 0x08, 0x10, 0x45, - 0x91, 0x6d, 0xe3, 0xb6, 0x59, 0xd0, 0x2a, 0x2b, 0x96, 0xc2, 0xa9, 0xc2, - 0x84, 0xab, 0x2b, 0xe0, 0x2c, 0x03, 0x9d, 0xd2, 0x41, 0xaa, 0x57, 0x9e, - 0x5a, 0x83, 0x63, 0xfd, 0x98, 0x44, 0xdc, 0xa6, 0x0f, 0xee, 0x4a, 0x48, - 0x22, 0x3b, 0x68, 0x66, 0x25, 0xa6, 0x79, 0xab, 0x53, 0x53, 0x55, 0x4e, - 0x95, 0x88, 0xaa, 0x20, 0x66, 0x13, 0x9a, 0xaa, 0x61, 0x32, 0xb5, 0x0e, - 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0xce, 0xc1, 0x43, 0x91, 0x07, 0x4e, 0x4b, 0x8c, 0xb3, 0xef, 0xb0, - 0x74, 0xd9, 0x59, 0xe3, 0xf6, 0x9a, 0xc9, 0x27, 0xbe, 0x36, 0xa2, 0x37, - 0xa3, 0xed, 0x6f, 0x78, 0x7e, 0x8e, 0x01, 0x43, 0x86, 0x7a, 0x46, 0xca, - 0xb5, 0x0e, 0xe1, 0xae, 0xf9, 0x6a, 0x1d, 0x1b, 0x16, 0xd6, 0x20, 0xb1, - 0x8e, 0xa9, 0x5e, 0xff, 0xb1, 0xed, 0xa4, 0xb0, 0xf7, 0xd4, 0x76, 0x53, - 0x69, 0x4d, 0x6c, 0xe7, 0x5f, 0xe5, 0x92, 0x4b, 0x42, 0xb8, 0xc7, 0x5f, - 0x4d, 0xff, 0x75, 0xce, 0xad, 0x8b, 0x97, 0xea, 0x93, 0xca, 0xa2, 0xfb, - 0x85, 0x50, 0x39, 0xad, 0x0e, 0xe1, 0xff, 0xbf, 0x14, 0x56, 0xb5, 0xd7, - 0x5c, 0x05, 0x77, 0xee, 0x82, 0x9d, 0xbb, 0xf9, 0x11, 0x55, 0x3f, 0xe0, - 0x02, 0xdf, 0xd6, 0x31, 0xde, 0x16, 0x46, 0xad, 0x37, 0x47, 0x21, 0x18, - 0x03, 0x6e, 0x77, 0x68, 0x90, 0x23, 0xc6, 0xff, 0x44, 0xe2, 0x4e, 0xb0, - 0x9d, 0x0f, 0x34, 0xf3, 0xf8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, - 0x97, 0x04, 0xc9, 0x61, 0x11, 0x00, 0x00, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0xcc, 0x58, + 0x5f, 0x6f, 0xdb, 0x36, 0x10, 0x7f, 0xd7, 0xa7, 0x38, 0x18, 0x41, 0x20, + 0x05, 0x8a, 0x12, 0x6c, 0x45, 0x1f, 0x0c, 0xe4, 0xc1, 0x69, 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 0xfb, 0x01, 0xa4, 0x11, 0x4e, 0x87, 0x48, 0xee, 0x64, 0x30, + 0xf6, 0x22, 0x85, 0x61, 0xe7, 0xfd, 0x86, 0xd1, 0x7c, 0x19, 0x83, 0x96, + 0x4e, 0x99, 0xf4, 0x4d, 0x72, 0x29, 0x8e, 0x5e, 0xa3, 0x7e, 0x2e, 0x4a, + 0x8a, 0x91, 0x75, 0x34, 0xca, 0x97, 0xe8, 0xba, 0x36, 0xd8, 0x1e, 0xd6, + 0x72, 0x8e, 0xe8, 0xf7, 0xc6, 0x66, 0xa3, 0xf6, 0x61, 0xdb, 0x1b, 0x1a, + 0x77, 0x08, 0x08, 0x19, 0x9c, 0x31, 0x95, 0x62, 0xe4, 0x43, 0x92, 0x81, + 0x1f, 0xcb, 0xf3, 0x21, 0x95, 0x52, 0xd9, 0x97, 0x54, 0x6c, 0x4a, 0x0e, + 0x2c, 0xa9, 0xa8, 0x08, 0xb3, 0xf8, 0x39, 0x0a, 0xd4, 0x4e, 0x65, 0x30, + 0x1e, 0x82, 0x70, 0x03, 0x67, 0x1b, 0x95, 0xe8, 0x7f, 0x46, 0xb8, 0x53, + 0x2f, 0x17, 0xe1, 0xa6, 0x07, 0xe1, 0x05, 0xfe, 0x99, 0x36, 0xdf, 0x6b, + 0xaa, 0x22, 0xd9, 0x5b, 0x4d, 0x7e, 0xa3, 0xc5, 0x3e, 0x84, 0x21, 0x27, + 0x92, 0xfd, 0x95, 0x1a, 0x92, 0xc8, 0xab, 0x11, 0xec, 0xd2, 0xec, 0xc6, + 0x6c, 0xea, 0x32, 0x9f, 0xfe, 0xf0, 0x19, 0x86, 0x37, 0x27, 0x81, 0x0d, + 0x9f, 0x25, 0x33, 0x8c, 0xa7, 0xc9, 0x55, 0xb1, 0x15, 0x67, 0x19, 0xa3, + 0x25, 0x2a, 0x63, 0x61, 0x3c, 0xf1, 0x0e, 0x68, 0x4c, 0x05, 0x67, 0x15, + 0xc5, 0x7a, 0x48, 0x44, 0xfe, 0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x77, 0xee, 0x82, 0x9d, + 0xbb, 0xf9, 0x11, 0x55, 0x3f, 0xe0, 0x02, 0xdf, 0xe6, 0x31, 0xde, 0x16, + 0x06, 0x2d, 0xcb, 0x41, 0x0c, 0x46, 0x80, 0xdb, 0x1d, 0x0a, 0xe4, 0x1b, + 0xe3, 0x7f, 0x22, 0x70, 0xc7, 0xd9, 0xce, 0x07, 0x9a, 0x79, 0xfc, 0x37, + 0x00, 0x00, 0xff, 0xff, 0x10, 0x3d, 0x69, 0x8c, 0xd4, 0x12, 0x00, 0x00, }, "sqlc/tmpl/fields.tmpl", ) diff --git a/sqlc/sqlc.go b/sqlc/sqlc.go index aaeb130..5ee7526 100644 --- a/sqlc/sqlc.go +++ b/sqlc/sqlc.go @@ -3,9 +3,11 @@ package sqlc import ( "bytes" "database/sql" + "database/sql/driver" "io" "reflect" "strings" + "time" ) type PredicateType int @@ -214,3 +216,22 @@ func Qualified(parts ...string) string { } return strings.Join(tmp, ".") } + +type NullableTime struct { + Time time.Time + Valid bool // Valid is true if Time is not NULL +} + +// Scan implements the Scanner interface. +func (self *NullableTime) Scan(value interface{}) error { + self.Time, self.Valid = value.(time.Time) + return nil +} + +// Value implements the driver Valuer interface. +func (self NullableTime) Value() (driver.Value, error) { + if !self.Valid { + return nil, nil + } + return self.Time, nil +} diff --git a/sqlc/tmpl/fields.tmpl b/sqlc/tmpl/fields.tmpl index 4b2b6d9..d3bf229 100644 --- a/sqlc/tmpl/fields.tmpl +++ b/sqlc/tmpl/fields.tmpl @@ -6,17 +6,25 @@ package sqlc import ( + "database/sql" "reflect" "time" ) var ( - typeString = reflect.TypeOf("") typeBool = reflect.TypeOf(false) - typeInt = reflect.TypeOf(int(0)) - typeInt64 = reflect.TypeOf(int64(0)) typeFloat32 = reflect.TypeOf(float32(0.)) typeFloat64 = reflect.TypeOf(float64(0.)) + typeInt = reflect.TypeOf(int(0)) + typeInt64 = reflect.TypeOf(int64(0)) + typeNullBool = reflect.TypeOf(sql.NullBool{}) + typeNullFloat32 = reflect.TypeOf(sql.NullFloat64{}) + typeNullFloat64 = reflect.TypeOf(sql.NullFloat64{}) + typeNullInt = reflect.TypeOf(sql.NullInt64{}) + typeNullInt64 = reflect.TypeOf(sql.NullInt64{}) + typeNullString = reflect.TypeOf(sql.NullString{}) + typeNullTime = reflect.TypeOf(NullableTime{}) + typeString = reflect.TypeOf("") typeTime = reflect.TypeOf(time.Unix(0, 0)) ) From a8437cce54086063f042555105384ec4760180c5 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Fri, 9 Jan 2015 18:35:49 -0500 Subject: [PATCH 05/17] add set interface support -- yes sometimes it can be helpful --- sqlc/fields.go | 56 ++++++------- sqlc/insert.go | 2 +- sqlc/schema.go | 190 +++++++++++++++++++++--------------------- sqlc/sqlc.go | 2 +- sqlc/tmpl/fields.tmpl | 4 +- 5 files changed, 127 insertions(+), 127 deletions(-) diff --git a/sqlc/fields.go b/sqlc/fields.go index 4b5796b..e0e4807 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -94,117 +94,117 @@ type UpdateSetStep interface { func (i *insert) SetString(f StringField, v string) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetBool(f BoolField, v bool) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetInt(f IntField, v int) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetInt64(f Int64Field, v int64) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetFloat32(f Float32Field, v float32) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetFloat64(f Float64Field, v float64) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetTime(f TimeField, v time.Time) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetNullString(f NullStringField, v sql.NullString) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetNullBool(f NullBoolField, v sql.NullBool) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetNullInt(f NullIntField, v sql.NullInt64) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetNullInt64(f NullInt64Field, v sql.NullInt64) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetNullFloat32(f NullFloat32Field, v sql.NullFloat64) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (i *insert) SetNullTime(f NullTimeField, v NullableTime) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } func (u *update) SetString(f StringField, v string) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetBool(f BoolField, v bool) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetInt(f IntField, v int) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetInt64(f Int64Field, v int64) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetFloat32(f Float32Field, v float32) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetFloat64(f Float64Field, v float64) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetTime(f TimeField, v time.Time) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetNullString(f NullStringField, v sql.NullString) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetNullBool(f NullBoolField, v sql.NullBool) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetNullInt(f NullIntField, v sql.NullInt64) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetNullInt64(f NullInt64Field, v sql.NullInt64) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetNullFloat32(f NullFloat32Field, v sql.NullFloat64) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } func (u *update) SetNullTime(f NullTimeField, v NullableTime) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } diff --git a/sqlc/insert.go b/sqlc/insert.go index 32d5011..332603e 100644 --- a/sqlc/insert.go +++ b/sqlc/insert.go @@ -30,7 +30,7 @@ func (i *insert) Fetch(d Dialect, db *sql.DB) (*sql.Row, error) { return db.QueryRow(buf.String(), args...), nil } -func (i *insert) set(f TableField, v interface{}) InsertSetMoreStep { +func (i *insert) Set(f TableField, v interface{}) InsertSetMoreStep { binding := TableFieldBinding{Field: f, Value: v} i.bindings = append(i.bindings, binding) return i diff --git a/sqlc/schema.go b/sqlc/schema.go index 73109c3..08639a6 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -31,100 +31,100 @@ func sqlc_tmpl_fields_tmpl() ([]byte, error) { 0x5f, 0x6f, 0xdb, 0x36, 0x10, 0x7f, 0xd7, 0xa7, 0x38, 0x18, 0x41, 0x20, 0x05, 0x8a, 0x12, 0x6c, 0x45, 0x1f, 0x0c, 0xe4, 0xc1, 0x69, 0x9d, 0xd5, 0x83, 0xeb, 0x04, 0xb1, 0xb3, 0x60, 0x4f, 0x03, 0x23, 0x53, 0x2e, 0x37, - 0x95, 0xf2, 0x24, 0x3a, 0x4b, 0x61, 0xe8, 0xbb, 0x8f, 0x47, 0x52, 0x0c, - 0x25, 0x53, 0x8e, 0x8d, 0x61, 0x45, 0xf3, 0x50, 0x4b, 0xc7, 0xfb, 0xf3, - 0xbb, 0xbb, 0xdf, 0x91, 0x54, 0x2f, 0x2e, 0x60, 0xf1, 0x69, 0x32, 0x87, - 0x9b, 0xc9, 0x74, 0x0c, 0x8f, 0xa3, 0x39, 0x8c, 0x1e,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, 0x73, - 0xc6, 0xb8, 0x72, 0x65, 0xd5, 0x66, 0x9b, 0x3c, 0xf7, 0x27, 0x22, 0xeb, - 0x90, 0x34, 0xab, 0xdb, 0xda, 0xd5, 0xef, 0xcd, 0xaa, 0x31, 0x31, 0xa9, - 0x78, 0xac, 0x7c, 0x90, 0xf6, 0x5a, 0x79, 0x33, 0x6d, 0x2c, 0x54, 0x8e, - 0x3b, 0xfa, 0xfb, 0x62, 0x78, 0x2c, 0xe6, 0xa2, 0x64, 0x7c, 0xd5, 0x6f, - 0xa2, 0xd7, 0xdb, 0x36, 0x0b, 0xc9, 0x87, 0x5d, 0x0b, 0x5c, 0x21, 0x4f, - 0x39, 0xc5, 0xd5, 0x57, 0xfd, 0x3e, 0xff, 0x83, 0x41, 0xa3, 0xe1, 0xf7, - 0x86, 0x9c, 0x4b, 0x1e, 0x38, 0x7b, 0x09, 0x2f, 0x63, 0xc0, 0x86, 0x49, - 0xfa, 0xa1, 0x36, 0x4c, 0x78, 0x45, 0x4b, 0x31, 0xa7, 0x62, 0x2e, 0xe8, - 0x1a, 0x64, 0x43, 0x69, 0x99, 0x91, 0x94, 0xc2, 0x56, 0xba, 0x93, 0xdc, - 0x2f, 0x09, 0x97, 0x04, 0x3f, 0xf9, 0x23, 0x86, 0x13, 0xa1, 0x26, 0x00, - 0x8d, 0x14, 0xfb, 0x01, 0xa4, 0x11, 0x4e, 0x87, 0x48, 0xee, 0x64, 0x30, - 0xf6, 0x22, 0x85, 0x61, 0xe7, 0xfd, 0x86, 0xd1, 0x7c, 0x19, 0x83, 0x96, - 0x4e, 0x99, 0xf4, 0x4d, 0x72, 0x29, 0x8e, 0x5e, 0xa3, 0x7e, 0x2e, 0x4a, - 0x8a, 0x91, 0x75, 0x34, 0xca, 0x97, 0xe8, 0xba, 0x36, 0xd8, 0x1e, 0xd6, - 0x72, 0x8e, 0xe8, 0xf7, 0xc6, 0x66, 0xa3, 0xf6, 0x61, 0xdb, 0x1b, 0x1a, - 0x77, 0x08, 0x08, 0x19, 0x9c, 0x31, 0x95, 0x62, 0xe4, 0x43, 0x92, 0x81, - 0x1f, 0xcb, 0xf3, 0x21, 0x95, 0x52, 0xd9, 0x97, 0x54, 0x6c, 0x4a, 0x0e, - 0x2c, 0xa9, 0xa8, 0x08, 0xb3, 0xf8, 0x39, 0x0a, 0xd4, 0x4e, 0x65, 0x30, - 0x1e, 0x82, 0x70, 0x03, 0x67, 0x1b, 0x95, 0xe8, 0x7f, 0x46, 0xb8, 0x53, - 0x2f, 0x17, 0xe1, 0xa6, 0x07, 0xe1, 0x05, 0xfe, 0x99, 0x36, 0xdf, 0x6b, - 0xaa, 0x22, 0xd9, 0x5b, 0x4d, 0x7e, 0xa3, 0xc5, 0x3e, 0x84, 0x21, 0x27, - 0x92, 0xfd, 0x95, 0x1a, 0x92, 0xc8, 0xab, 0x11, 0xec, 0xd2, 0xec, 0xc6, - 0x6c, 0xea, 0x32, 0x9f, 0xfe, 0xf0, 0x19, 0x86, 0x37, 0x27, 0x81, 0x0d, - 0x9f, 0x25, 0x33, 0x8c, 0xa7, 0xc9, 0x55, 0xb1, 0x15, 0x67, 0x19, 0xa3, - 0x25, 0x2a, 0x63, 0x61, 0x3c, 0xf1, 0x0e, 0x68, 0x4c, 0x05, 0x67, 0x15, - 0xc5, 0x7a, 0x48, 0x44, 0xfe, 0x14, 0xde, 0x4e, 0xd2, 0xed, 0xc0, 0xa9, - 0x54, 0x10, 0xc5, 0xb4, 0xf8, 0x07, 0x81, 0x75, 0x15, 0xb7, 0xe8, 0x6a, - 0x08, 0xf8, 0x2f, 0xe2, 0xd3, 0x08, 0x04, 0xa8, 0x5e, 0x7c, 0xcf, 0xe0, - 0x31, 0xd8, 0x9c, 0x87, 0x20, 0x6a, 0x2f, 0x57, 0xf6, 0xd6, 0x4e, 0x77, - 0x72, 0x5f, 0x34, 0xc4, 0xbc, 0x49, 0x85, 0x42, 0xe7, 0xe4, 0x20, 0xdf, - 0x6c, 0x68, 0x39, 0x09, 0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2, 0x2b, 0x43, 0x7a, 0xf3, 0xb6, 0xfd, 0x0d, 0xcf, 0xcf, 0x21, - 0xa0, 0xcb, 0x58, 0xaf, 0x48, 0xba, 0xd6, 0x31, 0xdc, 0x35, 0xff, 0x51, - 0x30, 0x34, 0x28, 0xac, 0x40, 0xc6, 0x3a, 0xa6, 0x7a, 0xfe, 0x63, 0xdb, - 0x49, 0x61, 0xef, 0xa9, 0xed, 0xa6, 0xd2, 0x5a, 0xd8, 0x4e, 0xbf, 0xc8, - 0x91, 0x4b, 0x63, 0xb8, 0xc7, 0x5f, 0x0d, 0xff, 0x6d, 0xcc, 0xad, 0x8b, - 0x97, 0xea, 0x93, 0xca, 0xa2, 0xfb, 0x85, 0x50, 0x39, 0xad, 0x8e, 0xe1, - 0xff, 0xbf, 0x14, 0x56, 0x75, 0xd0, 0x5c, 0x05, 0x77, 0xee, 0x82, 0x9d, - 0xbb, 0xf9, 0x11, 0x55, 0x3f, 0xe0, 0x02, 0xdf, 0xe6, 0x31, 0xde, 0x16, - 0x06, 0x2d, 0xcb, 0x41, 0x0c, 0x46, 0x80, 0xdb, 0x1d, 0x0a, 0xe4, 0x1b, - 0xe3, 0x7f, 0x22, 0x70, 0xc7, 0xd9, 0xce, 0x07, 0x9a, 0x79, 0xfc, 0x37, - 0x00, 0x00, 0xff, 0xff, 0x10, 0x3d, 0x69, 0x8c, 0xd4, 0x12, 0x00, 0x00, + 0x5c, 0x67, 0x55, 0x7b, 0x2b, 0xda, 0x5b, 0xcd, 0xde, 0x4a, 0xf6, 0x55, + 0xb1, 0x3a, 0x76, 0x90, 0x47, 0x04, 0x1c, 0xf7, 0x20, 0x5d, 0x31, 0xb7, + 0x54, 0x71, 0xa4, 0x92, 0x3a, 0xc2, 0xd7, 0x67, 0xf6, 0xed, 0x89, 0x77, + 0x38, 0xc4, 0xb9, 0x37, 0xce, 0x68, 0xf0, 0x07, 0x83, 0xe6, 0x10, 0xe9, + 0x4a, 0xf7, 0x4c, 0x58, 0x0d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, 0xed, 0x7c, 0xa1, 0x99, 0xc7, 0x7f, 0x03, + 0x00, 0x00, 0xff, 0xff, 0xee, 0xe3, 0x46, 0x2b, 0xd6, 0x12, 0x00, 0x00, }, "sqlc/tmpl/fields.tmpl", ) @@ -254,10 +254,10 @@ type _bintree_t struct { var _bintree = &_bintree_t{nil, map[string]*_bintree_t{ "sqlc": &_bintree_t{nil, map[string]*_bintree_t{ "tmpl": &_bintree_t{nil, map[string]*_bintree_t{ - "fields.tmpl": &_bintree_t{sqlc_tmpl_fields_tmpl, map[string]*_bintree_t{ - }}, "schema.tmpl": &_bintree_t{sqlc_tmpl_schema_tmpl, map[string]*_bintree_t{ }}, + "fields.tmpl": &_bintree_t{sqlc_tmpl_fields_tmpl, map[string]*_bintree_t{ + }}, }}, }}, }} diff --git a/sqlc/sqlc.go b/sqlc/sqlc.go index 5ee7526..a9fcdab 100644 --- a/sqlc/sqlc.go +++ b/sqlc/sqlc.go @@ -191,7 +191,7 @@ func (u *update) Where(c ...Condition) Executable { return u } -func (u *update) set(f TableField, v interface{}) UpdateSetMoreStep { +func (u *update) Set(f TableField, v interface{}) UpdateSetMoreStep { binding := TableFieldBinding{Field: f, Value: v} u.bindings = append(u.bindings, binding) return u diff --git a/sqlc/tmpl/fields.tmpl b/sqlc/tmpl/fields.tmpl index d3bf229..510fa6b 100644 --- a/sqlc/tmpl/fields.tmpl +++ b/sqlc/tmpl/fields.tmpl @@ -42,13 +42,13 @@ type UpdateSetStep interface { {{ range $_, $t := .types }} func (i *insert) Set{{ $t.Prefix }}(f {{ $t.Prefix }}Field, v {{ $t.Literal }}) InsertSetMoreStep { - return i.set(f,v) + return i.Set(f, v) } {{ end }} {{ range $_, $t := .types }} func (u *update) Set{{ $t.Prefix }}(f {{ $t.Prefix }}Field, v {{ $t.Literal }}) UpdateSetMoreStep { - return u.set(f,v) + return u.Set(f, v) } {{ end }} From 0ec020ee297462e476077317a8d290f0c916210f Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Fri, 9 Jan 2015 18:48:58 -0500 Subject: [PATCH 06/17] open Set() in interfaces --- sqlc/fields.go | 2 + sqlc/schema.go | 197 +++++++++++++++++++++--------------------- sqlc/tmpl/fields.tmpl | 2 + 3 files changed, 103 insertions(+), 98 deletions(-) diff --git a/sqlc/fields.go b/sqlc/fields.go index e0e4807..c4c6244 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -29,6 +29,7 @@ var ( ) type InsertSetStep interface { + Set(TableField, interface{}) InsertSetMoreStep SetString(StringField, string) InsertSetMoreStep @@ -61,6 +62,7 @@ type InsertSetStep interface { } type UpdateSetStep interface { + Set(TableField, interface{}) UpdateSetMoreStep SetString(StringField, string) UpdateSetMoreStep diff --git a/sqlc/schema.go b/sqlc/schema.go index 08639a6..1b3c66c 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -29,102 +29,103 @@ func sqlc_tmpl_fields_tmpl() ([]byte, error) { return bindata_read([]byte{ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0xcc, 0x58, 0x5f, 0x6f, 0xdb, 0x36, 0x10, 0x7f, 0xd7, 0xa7, 0x38, 0x18, 0x41, 0x20, - 0x05, 0x8a, 0x12, 0x6c, 0x45, 0x1f, 0x0c, 0xe4, 0xc1, 0x69, 0x9d, 0xd5, - 0x83, 0xeb, 0x04, 0xb1, 0xb3, 0x60, 0x4f, 0x03, 0x23, 0x53, 0x2e, 0x37, - 0x55, 0xf2, 0x24, 0x3a, 0x4b, 0x61, 0xe8, 0xbb, 0xef, 0x8e, 0xa4, 0x18, - 0x4a, 0x96, 0x1c, 0x1b, 0xc3, 0x8a, 0xe6, 0xa1, 0x96, 0x8e, 0xf7, 0xe7, - 0x77, 0x77, 0xbf, 0x23, 0xa9, 0x5e, 0x5c, 0xc0, 0xe2, 0xd3, 0x64, 0x0e, - 0x37, 0x93, 0xe9, 0x18, 0x1e, 0x47, 0x73, 0x18, 0x3d, 0x2c, 0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, 0x43, 0x80, 0x2f, 0xe0, 0x4c, 0xa8, 0x14, 0x83, 0x2e, 0x24, 0x09, - 0x74, 0x63, 0x79, 0x3e, 0xa4, 0x52, 0x2a, 0xfb, 0x82, 0xcb, 0x4d, 0x91, - 0x81, 0x88, 0x70, 0xc1, 0x4f, 0xd0, 0x32, 0xf0, 0xd4, 0x56, 0x65, 0x40, - 0x1e, 0x02, 0x71, 0x03, 0x67, 0x1b, 0x95, 0xe9, 0x7f, 0x86, 0xb8, 0x53, - 0x30, 0x17, 0xe2, 0xa6, 0x0f, 0xe2, 0x05, 0xfd, 0x99, 0x46, 0xdf, 0x6b, - 0xb2, 0x12, 0xdd, 0x1b, 0x6d, 0x7e, 0xa3, 0xc9, 0x5d, 0x10, 0xfd, 0x8c, - 0x21, 0xff, 0x4b, 0x35, 0x26, 0x41, 0xa7, 0x86, 0xb7, 0x4b, 0xb4, 0x1b, - 0xb3, 0xad, 0x63, 0x42, 0xfd, 0xe1, 0x13, 0x0a, 0x6f, 0xce, 0x02, 0x1b, - 0x3e, 0x89, 0x66, 0x14, 0x4f, 0xd3, 0xab, 0x14, 0xab, 0x4c, 0x24, 0x82, - 0x17, 0xa4, 0x4c, 0x95, 0xe9, 0x88, 0x77, 0x40, 0x67, 0x4a, 0x38, 0x2b, - 0x39, 0xd5, 0x03, 0x11, 0x75, 0xa7, 0xf0, 0x76, 0x92, 0x6e, 0x0b, 0x4e, - 0x51, 0x41, 0xe6, 0xd3, 0xfc, 0x1f, 0x02, 0xd6, 0x56, 0xdc, 0x92, 0xab, - 0x21, 0xd0, 0xbf, 0x84, 0x4f, 0x23, 0x90, 0xa0, 0x7a, 0xf1, 0x3d, 0x83, - 0x87, 0x60, 0x73, 0x1e, 0x82, 0xac, 0x3a, 0xb9, 0xb2, 0xb7, 0x76, 0xba, - 0x93, 0xfb, 0xa2, 0x11, 0xe6, 0x4d, 0x2c, 0x15, 0x3a, 0x27, 0x07, 0x7c, - 0xb3, 0xa1, 0x71, 0x14, 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, 0x57, 0x11, 0xcf, 0xd6, + 0xf0, 0x73, 0x96, 0x73, 0x32, 0x46, 0x03, 0x1c, 0x96, 0x9c, 0x49, 0x9c, + 0x88, 0x93, 0xdf, 0x02, 0x38, 0x51, 0x7a, 0x64, 0x28, 0x8a, 0x1e, 0x17, + 0xed, 0x8f, 0xc6, 0x49, 0x85, 0x77, 0x88, 0x4e, 0xbc, 0xa2, 0xd0, 0x6f, + 0xbd, 0xdb, 0x40, 0x46, 0x3a, 0x13, 0x18, 0x8e, 0xa5, 0x28, 0xee, 0x8d, + 0xc6, 0xe5, 0x92, 0x5c, 0x97, 0x36, 0x99, 0x87, 0x15, 0x0e, 0x1e, 0xff, + 0x07, 0xc9, 0xd4, 0x86, 0xdf, 0x25, 0x99, 0x9e, 0x68, 0xdb, 0x64, 0xf6, + 0x86, 0xa6, 0x3d, 0x08, 0x7c, 0x01, 0x67, 0x42, 0xd7, 0x64, 0xd8, 0x85, + 0x24, 0x81, 0x6e, 0x2c, 0x2f, 0x87, 0x94, 0x56, 0x97, 0x2b, 0xe7, 0x6a, + 0x9d, 0x4b, 0x10, 0x21, 0xd5, 0x2d, 0x41, 0xcb, 0xa1, 0xa7, 0x37, 0x43, + 0x0b, 0xf2, 0x10, 0x88, 0x6b, 0x38, 0x5b, 0xeb, 0x4c, 0xff, 0x35, 0xc4, + 0x9d, 0x82, 0xb9, 0x10, 0xd7, 0x7d, 0x10, 0x2f, 0xe8, 0xcf, 0x32, 0xe3, + 0xde, 0x8c, 0x03, 0xf5, 0xbf, 0xc1, 0x8b, 0x37, 0x9a, 0xdc, 0x05, 0xd1, + 0x97, 0x0c, 0x27, 0xac, 0xd0, 0x83, 0x38, 0xec, 0xd4, 0xf0, 0x76, 0x99, + 0x79, 0x63, 0x0f, 0x0e, 0x4c, 0xa8, 0x3f, 0x7c, 0x42, 0xe1, 0xed, 0x69, + 0x53, 0x87, 0x4f, 0xc2, 0x39, 0xc5, 0x33, 0xf4, 0x2a, 0xc4, 0xb3,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, 0x13, 0xa1, 0x70, 0x5a, 0x1d, 0xc0, 0x7f, + 0x7f, 0x29, 0x2c, 0x4a, 0xaf, 0xba, 0x0a, 0xee, 0xdc, 0x05, 0x5b, 0x77, + 0xf3, 0x23, 0xaa, 0x7e, 0xc0, 0x05, 0xbe, 0xc9, 0x63, 0xba, 0x2d, 0x0c, + 0x1a, 0x96, 0x83, 0x00, 0xac, 0x80, 0xb6, 0x3b, 0x12, 0xe0, 0x9b, 0x90, + 0xbf, 0x13, 0x70, 0xc7, 0xd9, 0xce, 0x17, 0x9a, 0x7d, 0xfc, 0x3b, 0x00, + 0x00, 0xff, 0xff, 0x0c, 0xaa, 0x3b, 0xbe, 0x38, 0x13, 0x00, 0x00, }, "sqlc/tmpl/fields.tmpl", ) @@ -254,10 +255,10 @@ type _bintree_t struct { var _bintree = &_bintree_t{nil, map[string]*_bintree_t{ "sqlc": &_bintree_t{nil, map[string]*_bintree_t{ "tmpl": &_bintree_t{nil, map[string]*_bintree_t{ - "schema.tmpl": &_bintree_t{sqlc_tmpl_schema_tmpl, map[string]*_bintree_t{ - }}, "fields.tmpl": &_bintree_t{sqlc_tmpl_fields_tmpl, map[string]*_bintree_t{ }}, + "schema.tmpl": &_bintree_t{sqlc_tmpl_schema_tmpl, map[string]*_bintree_t{ + }}, }}, }}, }} diff --git a/sqlc/tmpl/fields.tmpl b/sqlc/tmpl/fields.tmpl index 510fa6b..33822aa 100644 --- a/sqlc/tmpl/fields.tmpl +++ b/sqlc/tmpl/fields.tmpl @@ -29,12 +29,14 @@ var ( ) type InsertSetStep interface { + Set(TableField, interface{}) InsertSetMoreStep {{ range $_, $t := .types }} Set{{ $t.Prefix }}({{ $t.Prefix }}Field, {{ $t.Literal }}) InsertSetMoreStep {{ end }} } type UpdateSetStep interface { + Set(TableField, interface{}) UpdateSetMoreStep {{ range $_, $t := .types }} Set{{ $t.Prefix }}({{ $t.Prefix }}Field, {{ $t.Literal }}) UpdateSetMoreStep {{ end }} From 624763a52cba8c43e0216055baa26e9781b05227 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Thu, 29 Jan 2015 12:12:33 -0500 Subject: [PATCH 07/17] added substring support --- meta/types.go | 2 + sqlc/fields.go | 116 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/meta/types.go b/meta/types.go index 18895a4..ed8e156 100644 --- a/meta/types.go +++ b/meta/types.go @@ -43,4 +43,6 @@ var Funcs = []FunctionInfo{ FunctionInfo{Name: "Md5", Expr: "MD5(%s)"}, FunctionInfo{Name: "Lower", Expr: "LOWER(%s)"}, FunctionInfo{Name: "Hex", Expr: "HEX(%s)"}, + FunctionInfo{Name: "Substr2", Expr: "SUBSTR(%s, %v)"}, + FunctionInfo{Name: "Substr3", Expr: "SUBSTR(%s, %v, %v)"}, } diff --git a/sqlc/fields.go b/sqlc/fields.go index c4c6244..772a5d5 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -264,6 +264,10 @@ type Functional interface { Hex() Field + Substr2(_0 interface{}) Field + + Substr3(_0,_1 interface{}) Field + } @@ -569,6 +573,14 @@ func (c *stringField) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *stringField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *stringField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -771,6 +783,14 @@ func (c *boolField) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *boolField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *boolField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -973,6 +993,14 @@ func (c *intField) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *intField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *intField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -1175,6 +1203,14 @@ func (c *int64Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *int64Field) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *int64Field) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -1377,6 +1413,14 @@ func (c *float32Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *float32Field) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *float32Field) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -1579,6 +1623,14 @@ func (c *float64Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *float64Field) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *float64Field) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -1781,6 +1833,14 @@ func (c *timeField) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *timeField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *timeField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -1983,6 +2043,14 @@ func (c *nullstringField) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *nullstringField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *nullstringField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -2185,6 +2253,14 @@ func (c *nullboolField) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *nullboolField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *nullboolField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -2387,6 +2463,14 @@ func (c *nullintField) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *nullintField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *nullintField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -2589,6 +2673,14 @@ func (c *nullint64Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *nullint64Field) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *nullint64Field) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -2791,6 +2883,14 @@ func (c *nullfloat32Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *nullfloat32Field) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *nullfloat32Field) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -2993,6 +3093,14 @@ func (c *nullfloat64Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *nullfloat64Field) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *nullfloat64Field) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + @@ -3195,5 +3303,13 @@ func (c *nulltimeField) Hex() Field { return c.fct("Hex", "HEX(%s)") } +func (c *nulltimeField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *nulltimeField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + From 20ef52390812c570118f35c89102b06dcda1fa70 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Thu, 29 Jan 2015 12:18:15 -0500 Subject: [PATCH 08/17] added date support --- meta/types.go | 1 + sqlc/fields.go | 232 ++++++++++++++++++++++++++++++++++++++++++ sqlc/generator.go | 5 + sqlc/schema.go | 189 +++++++++++++++++----------------- sqlc/tmpl/fields.tmpl | 1 + 5 files changed, 334 insertions(+), 94 deletions(-) diff --git a/meta/types.go b/meta/types.go index ed8e156..59692d4 100644 --- a/meta/types.go +++ b/meta/types.go @@ -18,6 +18,7 @@ var Types = []TypeInfo{ TypeInfo{Prefix: "Float32", Literal: "float32"}, TypeInfo{Prefix: "Float64", Literal: "float64"}, TypeInfo{Prefix: "Time", Literal: "time.Time"}, + TypeInfo{Prefix: "Date", Literal: "time.Time"}, TypeInfo{Prefix: "NullString", Literal: "sql.NullString"}, TypeInfo{Prefix: "NullBool", Literal: "sql.NullBool"}, diff --git a/sqlc/fields.go b/sqlc/fields.go index 772a5d5..08b1b0c 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -26,6 +26,7 @@ var ( typeNullTime = reflect.TypeOf(NullableTime{}) typeString = reflect.TypeOf("") typeTime = reflect.TypeOf(time.Unix(0, 0)) + typeDate = reflect.TypeOf(time.Unix(0, 0)) ) type InsertSetStep interface { @@ -45,6 +46,8 @@ type InsertSetStep interface { SetTime(TimeField, time.Time) InsertSetMoreStep + SetDate(DateField, time.Time) InsertSetMoreStep + SetNullString(NullStringField, sql.NullString) InsertSetMoreStep SetNullBool(NullBoolField, sql.NullBool) InsertSetMoreStep @@ -78,6 +81,8 @@ type UpdateSetStep interface { SetTime(TimeField, time.Time) UpdateSetMoreStep + SetDate(DateField, time.Time) UpdateSetMoreStep + SetNullString(NullStringField, sql.NullString) UpdateSetMoreStep SetNullBool(NullBoolField, sql.NullBool) UpdateSetMoreStep @@ -123,6 +128,10 @@ func (i *insert) SetTime(f TimeField, v time.Time) InsertSetMoreStep { return i.Set(f, v) } +func (i *insert) SetDate(f DateField, v time.Time) InsertSetMoreStep { + return i.Set(f, v) +} + func (i *insert) SetNullString(f NullStringField, v sql.NullString) InsertSetMoreStep { return i.Set(f, v) } @@ -181,6 +190,10 @@ func (u *update) SetTime(f TimeField, v time.Time) UpdateSetMoreStep { return u.Set(f, v) } +func (u *update) SetDate(f DateField, v time.Time) UpdateSetMoreStep { + return u.Set(f, v) +} + func (u *update) SetNullString(f NullStringField, v sql.NullString) UpdateSetMoreStep { return u.Set(f, v) } @@ -228,6 +241,8 @@ type Reflectable interface { TimeField(name string) TimeField + DateField(name string) DateField + NullStringField(name string) NullStringField NullBoolField(name string) NullBoolField @@ -320,6 +335,13 @@ func (t table) TimeField(name string) TimeField { return &timeField{name: name, selection: t} } +func (s *selection) DateField(name string) DateField { + return &dateField{name: name} +} +func (t table) DateField(name string) DateField { + return &dateField{name: name, selection: t} +} + func (s *selection) NullStringField(name string) NullStringField { return &nullstringField{name: name} } @@ -1844,6 +1866,216 @@ func (c *timeField) Substr3(_0,_1 interface{}) Field { +type dateField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type DateField interface { + TableField + + Eq(value time.Time) Condition + IsEq(value DateField) JoinCondition + + Gt(value time.Time) Condition + IsGt(value DateField) JoinCondition + + Ge(value time.Time) Condition + IsGe(value DateField) JoinCondition + + Lt(value time.Time) Condition + IsLt(value DateField) JoinCondition + + Le(value time.Time) Condition + IsLe(value DateField) JoinCondition + +} + +func (c *dateField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *dateField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &dateField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &dateField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *dateField) As(alias string) Field { + return &dateField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *dateField) Alias() string { + return c.alias +} + +func (c *dateField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *dateField) Name() string { + return c.name +} + +func (c *dateField) Type() reflect.Type { + return typeDate +} + +func (c *dateField) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *dateField) Eq(pred time.Time) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *dateField) IsEq(pred DateField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *dateField) Gt(pred time.Time) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *dateField) IsGt(pred DateField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *dateField) Ge(pred time.Time) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *dateField) IsGe(pred DateField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *dateField) Lt(pred time.Time) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *dateField) IsLt(pred DateField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *dateField) Le(pred time.Time) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *dateField) IsLe(pred DateField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func Date(s Selectable, name string) DateField { + return &dateField{name: name, selection: s} +} + +////// + + +func (c *dateField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *dateField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *dateField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *dateField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *dateField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *dateField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *dateField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *dateField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *dateField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + +func (c *dateField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *dateField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + + + + type nullstringField struct { name string selection Selectable diff --git a/sqlc/generator.go b/sqlc/generator.go index abfa9a1..c4dc776 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -22,6 +22,7 @@ var float_32 = regexp.MustCompile("FLOAT") var float_64 = regexp.MustCompile("DOUBLE PRECISION") var varchar = regexp.MustCompile("VARCHAR|CHARACTER VARYING|TEXT") var ts = regexp.MustCompile("TIMESTAMP|DATETIME") +var date = regexp.MustCompile("DATE") var dbType = regexp.MustCompile("mysql|postgres|sqlite") type Provenance struct { @@ -189,6 +190,8 @@ func infoSchema(d Dialect, schema string, db *sql.DB) ([]TableMeta, error) { fieldType = "String" } else if ts.MatchString(colType.String) { fieldType = "Time" + } else if date.MatchString(colType.String) { + fieldType = "Date" } else if boolean.MatchString(colType.String) { fieldType = "Bool" } @@ -254,6 +257,8 @@ func sqlite(db *sql.DB) ([]TableMeta, error) { fieldType = "String" } else if ts.MatchString(colType.String) { fieldType = "Time" + } else if ts.MatchString(colType.String) { + fieldType = "Date" } else if boolean.MatchString(colType.String) { fieldType = "Bool" } diff --git a/sqlc/schema.go b/sqlc/schema.go index 1b3c66c..da418b8 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -28,104 +28,105 @@ func bindata_read(data []byte, name string) ([]byte, error) { func sqlc_tmpl_fields_tmpl() ([]byte, error) { return bindata_read([]byte{ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0xcc, 0x58, - 0x5f, 0x6f, 0xdb, 0x36, 0x10, 0x7f, 0xd7, 0xa7, 0x38, 0x18, 0x41, 0x20, - 0x07, 0x8a, 0x12, 0x6c, 0x45, 0x1f, 0x0c, 0xe4, 0xc1, 0x69, 0x9d, 0xd5, + 0x5f, 0x6f, 0xdb, 0x36, 0x10, 0x7f, 0xd7, 0xa7, 0x38, 0x18, 0x45, 0x20, + 0x07, 0x8a, 0x12, 0x6c, 0x45, 0x1f, 0x0c, 0xe4, 0xc1, 0x69, 0x9c, 0xd5, 0x83, 0xeb, 0x04, 0xb1, 0xb2, 0x60, 0x4f, 0x03, 0x23, 0x53, 0x29, 0x37, 0x95, 0xf2, 0x24, 0x3a, 0x4b, 0x61, 0xe8, 0xbb, 0xef, 0x8e, 0xa4, 0x64, 0x4a, 0x96, 0x1c, 0x7b, 0xc3, 0x8a, 0xe5, 0xa1, 0x96, 0x8e, 0xf7, 0xe7, - 0x77, 0x77, 0xbf, 0x23, 0xa9, 0x5e, 0x5c, 0x40, 0xf4, 0x69, 0xba, 0x80, + 0x77, 0x77, 0xbf, 0x23, 0xa9, 0x9e, 0x9f, 0x43, 0xf4, 0x69, 0xba, 0x80, 0x9b, 0xe9, 0x6c, 0x02, 0x8f, 0xe3, 0x05, 0x8c, 0x1f, 0xa2, 0xdb, 0x9f, - 0x26, 0xf3, 0xc9, 0xfd, 0x38, 0x9a, 0x7c, 0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9d, 0x93, - 0x03, 0xbe, 0xd5, 0xa1, 0x71, 0x14, 0x2a, 0x22, 0xa2, 0x98, 0xa5, 0x82, - 0x15, 0x5b, 0x2d, 0xac, 0x8d, 0xe9, 0x68, 0x45, 0x17, 0xcf, 0x89, 0xba, - 0x1b, 0xad, 0xb9, 0xc1, 0x6d, 0x37, 0xb7, 0x9d, 0xcd, 0x6b, 0xa5, 0x89, - 0x65, 0xae, 0x38, 0x35, 0xb1, 0x56, 0x61, 0x23, 0x14, 0x31, 0xec, 0x85, - 0xa5, 0x6b, 0xde, 0x31, 0x7f, 0x1f, 0x32, 0xb9, 0x14, 0x1a, 0x4f, 0x65, - 0xfa, 0x73, 0x26, 0x64, 0x9f, 0x65, 0x13, 0xe5, 0x10, 0x48, 0xb7, 0xe5, - 0x61, 0xcb, 0x56, 0x43, 0x87, 0x18, 0xce, 0xf6, 0xd5, 0x75, 0x58, 0xcf, - 0x8f, 0x3f, 0x6c, 0x16, 0xc8, 0x25, 0x42, 0x63, 0x81, 0xe4, 0x00, 0x73, - 0xdd, 0x7d, 0x88, 0xe9, 0xe2, 0xa6, 0xe7, 0x28, 0xd0, 0xe2, 0xc9, 0xeb, - 0x2a, 0xaf, 0xc5, 0xf4, 0x62, 0xc4, 0xe3, 0xfc, 0xb9, 0xa8, 0xc5, 0xf4, - 0x62, 0xc4, 0x1f, 0xbe, 0x88, 0x74, 0x39, 0xb2, 0x62, 0xfd, 0x42, 0xf2, - 0x63, 0xd0, 0x27, 0x31, 0x6e, 0x50, 0x6b, 0x19, 0x00, 0xc7, 0x58, 0xb6, - 0xdd, 0x01, 0x30, 0x8c, 0x00, 0x61, 0x18, 0x36, 0x4e, 0xa2, 0x2d, 0xbd, - 0x45, 0x02, 0xa7, 0x3a, 0x26, 0x5c, 0x5d, 0x81, 0x14, 0x29, 0x98, 0x94, - 0x0e, 0x62, 0xbd, 0xd6, 0x34, 0x1c, 0x1c, 0x99, 0xc7, 0x38, 0x94, 0x75, - 0xfa, 0xe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65, 0x13, 0x00, 0x00, }, "sqlc/tmpl/fields.tmpl", ) diff --git a/sqlc/tmpl/fields.tmpl b/sqlc/tmpl/fields.tmpl index 33822aa..8fdd1b6 100644 --- a/sqlc/tmpl/fields.tmpl +++ b/sqlc/tmpl/fields.tmpl @@ -26,6 +26,7 @@ var ( typeNullTime = reflect.TypeOf(NullableTime{}) typeString = reflect.TypeOf("") typeTime = reflect.TypeOf(time.Unix(0, 0)) + typeDate = reflect.TypeOf(time.Unix(0, 0)) ) type InsertSetStep interface { From 0dfe0dea509c78d7ecb039da98fc24822de5b16e Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Thu, 29 Jan 2015 12:29:26 -0500 Subject: [PATCH 09/17] added {nullable,}{date,time,datetime} support --- meta/types.go | 22 +- sqlc/fields.go | 2106 +++++++++++++++++++++++++++-------------- sqlc/schema.go | 193 ++-- sqlc/sqlc.go | 10 + sqlc/tmpl/fields.tmpl | 5 +- 5 files changed, 1524 insertions(+), 812 deletions(-) diff --git a/meta/types.go b/meta/types.go index 59692d4..2ffa697 100644 --- a/meta/types.go +++ b/meta/types.go @@ -11,22 +11,24 @@ type TypeInfo struct { } var Types = []TypeInfo{ - TypeInfo{Prefix: "String", Literal: "string"}, TypeInfo{Prefix: "Bool", Literal: "bool"}, - TypeInfo{Prefix: "Int", Literal: "int"}, - TypeInfo{Prefix: "Int64", Literal: "int64"}, + TypeInfo{Prefix: "Date", Literal: "time.Time"}, // TODO(shutej): test + TypeInfo{Prefix: "Datetime", Literal: "time.Time"}, // TODO(shutej): test TypeInfo{Prefix: "Float32", Literal: "float32"}, TypeInfo{Prefix: "Float64", Literal: "float64"}, - TypeInfo{Prefix: "Time", Literal: "time.Time"}, - TypeInfo{Prefix: "Date", Literal: "time.Time"}, - - TypeInfo{Prefix: "NullString", Literal: "sql.NullString"}, + TypeInfo{Prefix: "Int", Literal: "int"}, + TypeInfo{Prefix: "Int64", Literal: "int64"}, TypeInfo{Prefix: "NullBool", Literal: "sql.NullBool"}, + TypeInfo{Prefix: "NullDate", Literal: "NullableDate"}, // TODO(shutej): test + TypeInfo{Prefix: "NullDatetime", Literal: "NullableDatetime"}, // TODO(shutej): test + TypeInfo{Prefix: "NullFloat32", Literal: "sql.NullFloat64"}, // TODO(shutej): test + TypeInfo{Prefix: "NullFloat64", Literal: "sql.NullFloat64"}, TypeInfo{Prefix: "NullInt", Literal: "sql.NullInt64"}, // TODO(shutej): test TypeInfo{Prefix: "NullInt64", Literal: "sql.NullInt64"}, - TypeInfo{Prefix: "NullFloat32", Literal: "sql.NullFloat64"}, // TODO(shutej): test - TypeInfo{Prefix: "NullFloat64", Literal: "sql.NullFloat64"}, - TypeInfo{Prefix: "NullTime", Literal: "NullableTime"}, + TypeInfo{Prefix: "NullString", Literal: "sql.NullString"}, + TypeInfo{Prefix: "NullTime", Literal: "NullableTime"}, // TODO(shutej): test + TypeInfo{Prefix: "String", Literal: "string"}, + TypeInfo{Prefix: "Time", Literal: "time.Time"}, // TODO(shutej): test } type FunctionInfo struct { diff --git a/sqlc/fields.go b/sqlc/fields.go index 08b1b0c..3db8eb9 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -13,11 +13,15 @@ import ( var ( typeBool = reflect.TypeOf(false) + typeDate = reflect.TypeOf(time.Unix(0, 0)) + typeDatetime = reflect.TypeOf(time.Unix(0, 0)) typeFloat32 = reflect.TypeOf(float32(0.)) typeFloat64 = reflect.TypeOf(float64(0.)) typeInt = reflect.TypeOf(int(0)) typeInt64 = reflect.TypeOf(int64(0)) typeNullBool = reflect.TypeOf(sql.NullBool{}) + typeNullDate = reflect.TypeOf(NullableDate{}) + typeNullDatetime = reflect.TypeOf(NullableDatetime{}) typeNullFloat32 = reflect.TypeOf(sql.NullFloat64{}) typeNullFloat64 = reflect.TypeOf(sql.NullFloat64{}) typeNullInt = reflect.TypeOf(sql.NullInt64{}) @@ -26,93 +30,100 @@ var ( typeNullTime = reflect.TypeOf(NullableTime{}) typeString = reflect.TypeOf("") typeTime = reflect.TypeOf(time.Unix(0, 0)) - typeDate = reflect.TypeOf(time.Unix(0, 0)) ) type InsertSetStep interface { Set(TableField, interface{}) InsertSetMoreStep - SetString(StringField, string) InsertSetMoreStep - SetBool(BoolField, bool) InsertSetMoreStep - SetInt(IntField, int) InsertSetMoreStep + SetDate(DateField, time.Time) InsertSetMoreStep - SetInt64(Int64Field, int64) InsertSetMoreStep + SetDatetime(DatetimeField, time.Time) InsertSetMoreStep SetFloat32(Float32Field, float32) InsertSetMoreStep SetFloat64(Float64Field, float64) InsertSetMoreStep - SetTime(TimeField, time.Time) InsertSetMoreStep - - SetDate(DateField, time.Time) InsertSetMoreStep + SetInt(IntField, int) InsertSetMoreStep - SetNullString(NullStringField, sql.NullString) InsertSetMoreStep + SetInt64(Int64Field, int64) InsertSetMoreStep SetNullBool(NullBoolField, sql.NullBool) InsertSetMoreStep - SetNullInt(NullIntField, sql.NullInt64) InsertSetMoreStep + SetNullDate(NullDateField, NullableDate) InsertSetMoreStep - SetNullInt64(NullInt64Field, sql.NullInt64) InsertSetMoreStep + SetNullDatetime(NullDatetimeField, NullableDatetime) InsertSetMoreStep SetNullFloat32(NullFloat32Field, sql.NullFloat64) InsertSetMoreStep SetNullFloat64(NullFloat64Field, sql.NullFloat64) InsertSetMoreStep + SetNullInt(NullIntField, sql.NullInt64) InsertSetMoreStep + + SetNullInt64(NullInt64Field, sql.NullInt64) InsertSetMoreStep + + SetNullString(NullStringField, sql.NullString) InsertSetMoreStep + SetNullTime(NullTimeField, NullableTime) InsertSetMoreStep + SetString(StringField, string) InsertSetMoreStep + + SetTime(TimeField, time.Time) InsertSetMoreStep + } type UpdateSetStep interface { Set(TableField, interface{}) UpdateSetMoreStep - SetString(StringField, string) UpdateSetMoreStep - SetBool(BoolField, bool) UpdateSetMoreStep - SetInt(IntField, int) UpdateSetMoreStep + SetDate(DateField, time.Time) UpdateSetMoreStep - SetInt64(Int64Field, int64) UpdateSetMoreStep + SetDatetime(DatetimeField, time.Time) UpdateSetMoreStep SetFloat32(Float32Field, float32) UpdateSetMoreStep SetFloat64(Float64Field, float64) UpdateSetMoreStep - SetTime(TimeField, time.Time) UpdateSetMoreStep - - SetDate(DateField, time.Time) UpdateSetMoreStep + SetInt(IntField, int) UpdateSetMoreStep - SetNullString(NullStringField, sql.NullString) UpdateSetMoreStep + SetInt64(Int64Field, int64) UpdateSetMoreStep SetNullBool(NullBoolField, sql.NullBool) UpdateSetMoreStep - SetNullInt(NullIntField, sql.NullInt64) UpdateSetMoreStep + SetNullDate(NullDateField, NullableDate) UpdateSetMoreStep - SetNullInt64(NullInt64Field, sql.NullInt64) UpdateSetMoreStep + SetNullDatetime(NullDatetimeField, NullableDatetime) UpdateSetMoreStep SetNullFloat32(NullFloat32Field, sql.NullFloat64) UpdateSetMoreStep SetNullFloat64(NullFloat64Field, sql.NullFloat64) UpdateSetMoreStep + SetNullInt(NullIntField, sql.NullInt64) UpdateSetMoreStep + + SetNullInt64(NullInt64Field, sql.NullInt64) UpdateSetMoreStep + + SetNullString(NullStringField, sql.NullString) UpdateSetMoreStep + SetNullTime(NullTimeField, NullableTime) UpdateSetMoreStep + SetString(StringField, string) UpdateSetMoreStep + + SetTime(TimeField, time.Time) UpdateSetMoreStep + } -func (i *insert) SetString(f StringField, v string) InsertSetMoreStep { - return i.Set(f, v) -} - func (i *insert) SetBool(f BoolField, v bool) InsertSetMoreStep { return i.Set(f, v) } -func (i *insert) SetInt(f IntField, v int) InsertSetMoreStep { +func (i *insert) SetDate(f DateField, v time.Time) InsertSetMoreStep { return i.Set(f, v) } -func (i *insert) SetInt64(f Int64Field, v int64) InsertSetMoreStep { +func (i *insert) SetDatetime(f DatetimeField, v time.Time) InsertSetMoreStep { return i.Set(f, v) } @@ -124,19 +135,31 @@ func (i *insert) SetFloat64(f Float64Field, v float64) InsertSetMoreStep { return i.Set(f, v) } -func (i *insert) SetTime(f TimeField, v time.Time) InsertSetMoreStep { +func (i *insert) SetInt(f IntField, v int) InsertSetMoreStep { return i.Set(f, v) } -func (i *insert) SetDate(f DateField, v time.Time) InsertSetMoreStep { +func (i *insert) SetInt64(f Int64Field, v int64) InsertSetMoreStep { return i.Set(f, v) } -func (i *insert) SetNullString(f NullStringField, v sql.NullString) InsertSetMoreStep { +func (i *insert) SetNullBool(f NullBoolField, v sql.NullBool) InsertSetMoreStep { return i.Set(f, v) } -func (i *insert) SetNullBool(f NullBoolField, v sql.NullBool) InsertSetMoreStep { +func (i *insert) SetNullDate(f NullDateField, v NullableDate) InsertSetMoreStep { + return i.Set(f, v) +} + +func (i *insert) SetNullDatetime(f NullDatetimeField, v NullableDatetime) InsertSetMoreStep { + return i.Set(f, v) +} + +func (i *insert) SetNullFloat32(f NullFloat32Field, v sql.NullFloat64) InsertSetMoreStep { + return i.Set(f, v) +} + +func (i *insert) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) InsertSetMoreStep { return i.Set(f, v) } @@ -148,33 +171,33 @@ func (i *insert) SetNullInt64(f NullInt64Field, v sql.NullInt64) InsertSetMoreSt return i.Set(f, v) } -func (i *insert) SetNullFloat32(f NullFloat32Field, v sql.NullFloat64) InsertSetMoreStep { +func (i *insert) SetNullString(f NullStringField, v sql.NullString) InsertSetMoreStep { return i.Set(f, v) } -func (i *insert) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) InsertSetMoreStep { +func (i *insert) SetNullTime(f NullTimeField, v NullableTime) InsertSetMoreStep { return i.Set(f, v) } -func (i *insert) SetNullTime(f NullTimeField, v NullableTime) InsertSetMoreStep { +func (i *insert) SetString(f StringField, v string) InsertSetMoreStep { return i.Set(f, v) } +func (i *insert) SetTime(f TimeField, v time.Time) InsertSetMoreStep { + return i.Set(f, v) +} -func (u *update) SetString(f StringField, v string) UpdateSetMoreStep { - return u.Set(f, v) -} func (u *update) SetBool(f BoolField, v bool) UpdateSetMoreStep { return u.Set(f, v) } -func (u *update) SetInt(f IntField, v int) UpdateSetMoreStep { +func (u *update) SetDate(f DateField, v time.Time) UpdateSetMoreStep { return u.Set(f, v) } -func (u *update) SetInt64(f Int64Field, v int64) UpdateSetMoreStep { +func (u *update) SetDatetime(f DatetimeField, v time.Time) UpdateSetMoreStep { return u.Set(f, v) } @@ -186,19 +209,31 @@ func (u *update) SetFloat64(f Float64Field, v float64) UpdateSetMoreStep { return u.Set(f, v) } -func (u *update) SetTime(f TimeField, v time.Time) UpdateSetMoreStep { +func (u *update) SetInt(f IntField, v int) UpdateSetMoreStep { return u.Set(f, v) } -func (u *update) SetDate(f DateField, v time.Time) UpdateSetMoreStep { +func (u *update) SetInt64(f Int64Field, v int64) UpdateSetMoreStep { return u.Set(f, v) } -func (u *update) SetNullString(f NullStringField, v sql.NullString) UpdateSetMoreStep { +func (u *update) SetNullBool(f NullBoolField, v sql.NullBool) UpdateSetMoreStep { return u.Set(f, v) } -func (u *update) SetNullBool(f NullBoolField, v sql.NullBool) UpdateSetMoreStep { +func (u *update) SetNullDate(f NullDateField, v NullableDate) UpdateSetMoreStep { + return u.Set(f, v) +} + +func (u *update) SetNullDatetime(f NullDatetimeField, v NullableDatetime) UpdateSetMoreStep { + return u.Set(f, v) +} + +func (u *update) SetNullFloat32(f NullFloat32Field, v sql.NullFloat64) UpdateSetMoreStep { + return u.Set(f, v) +} + +func (u *update) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) UpdateSetMoreStep { return u.Set(f, v) } @@ -210,15 +245,19 @@ func (u *update) SetNullInt64(f NullInt64Field, v sql.NullInt64) UpdateSetMoreSt return u.Set(f, v) } -func (u *update) SetNullFloat32(f NullFloat32Field, v sql.NullFloat64) UpdateSetMoreStep { +func (u *update) SetNullString(f NullStringField, v sql.NullString) UpdateSetMoreStep { return u.Set(f, v) } -func (u *update) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) UpdateSetMoreStep { +func (u *update) SetNullTime(f NullTimeField, v NullableTime) UpdateSetMoreStep { return u.Set(f, v) } -func (u *update) SetNullTime(f NullTimeField, v NullableTime) UpdateSetMoreStep { +func (u *update) SetString(f StringField, v string) UpdateSetMoreStep { + return u.Set(f, v) +} + +func (u *update) SetTime(f TimeField, v time.Time) UpdateSetMoreStep { return u.Set(f, v) } @@ -227,36 +266,42 @@ func (u *update) SetNullTime(f NullTimeField, v NullableTime) UpdateSetMoreStep type Reflectable interface { - StringField(name string) StringField - BoolField(name string) BoolField - IntField(name string) IntField + DateField(name string) DateField - Int64Field(name string) Int64Field + DatetimeField(name string) DatetimeField Float32Field(name string) Float32Field Float64Field(name string) Float64Field - TimeField(name string) TimeField - - DateField(name string) DateField + IntField(name string) IntField - NullStringField(name string) NullStringField + Int64Field(name string) Int64Field NullBoolField(name string) NullBoolField - NullIntField(name string) NullIntField + NullDateField(name string) NullDateField - NullInt64Field(name string) NullInt64Field + NullDatetimeField(name string) NullDatetimeField NullFloat32Field(name string) NullFloat32Field NullFloat64Field(name string) NullFloat64Field + NullIntField(name string) NullIntField + + NullInt64Field(name string) NullInt64Field + + NullStringField(name string) NullStringField + NullTimeField(name string) NullTimeField + StringField(name string) StringField + + TimeField(name string) TimeField + } type Functional interface { @@ -286,13 +331,6 @@ type Functional interface { } -func (s *selection) StringField(name string) StringField { - return &stringField{name: name} -} -func (t table) StringField(name string) StringField { - return &stringField{name: name, selection: t} -} - func (s *selection) BoolField(name string) BoolField { return &boolField{name: name} } @@ -300,18 +338,18 @@ func (t table) BoolField(name string) BoolField { return &boolField{name: name, selection: t} } -func (s *selection) IntField(name string) IntField { - return &intField{name: name} +func (s *selection) DateField(name string) DateField { + return &dateField{name: name} } -func (t table) IntField(name string) IntField { - return &intField{name: name, selection: t} +func (t table) DateField(name string) DateField { + return &dateField{name: name, selection: t} } -func (s *selection) Int64Field(name string) Int64Field { - return &int64Field{name: name} +func (s *selection) DatetimeField(name string) DatetimeField { + return &datetimeField{name: name} } -func (t table) Int64Field(name string) Int64Field { - return &int64Field{name: name, selection: t} +func (t table) DatetimeField(name string) DatetimeField { + return &datetimeField{name: name, selection: t} } func (s *selection) Float32Field(name string) Float32Field { @@ -328,25 +366,18 @@ func (t table) Float64Field(name string) Float64Field { return &float64Field{name: name, selection: t} } -func (s *selection) TimeField(name string) TimeField { - return &timeField{name: name} -} -func (t table) TimeField(name string) TimeField { - return &timeField{name: name, selection: t} -} - -func (s *selection) DateField(name string) DateField { - return &dateField{name: name} +func (s *selection) IntField(name string) IntField { + return &intField{name: name} } -func (t table) DateField(name string) DateField { - return &dateField{name: name, selection: t} +func (t table) IntField(name string) IntField { + return &intField{name: name, selection: t} } -func (s *selection) NullStringField(name string) NullStringField { - return &nullstringField{name: name} +func (s *selection) Int64Field(name string) Int64Field { + return &int64Field{name: name} } -func (t table) NullStringField(name string) NullStringField { - return &nullstringField{name: name, selection: t} +func (t table) Int64Field(name string) Int64Field { + return &int64Field{name: name, selection: t} } func (s *selection) NullBoolField(name string) NullBoolField { @@ -356,18 +387,18 @@ func (t table) NullBoolField(name string) NullBoolField { return &nullboolField{name: name, selection: t} } -func (s *selection) NullIntField(name string) NullIntField { - return &nullintField{name: name} +func (s *selection) NullDateField(name string) NullDateField { + return &nulldateField{name: name} } -func (t table) NullIntField(name string) NullIntField { - return &nullintField{name: name, selection: t} +func (t table) NullDateField(name string) NullDateField { + return &nulldateField{name: name, selection: t} } -func (s *selection) NullInt64Field(name string) NullInt64Field { - return &nullint64Field{name: name} +func (s *selection) NullDatetimeField(name string) NullDatetimeField { + return &nulldatetimeField{name: name} } -func (t table) NullInt64Field(name string) NullInt64Field { - return &nullint64Field{name: name, selection: t} +func (t table) NullDatetimeField(name string) NullDatetimeField { + return &nulldatetimeField{name: name, selection: t} } func (s *selection) NullFloat32Field(name string) NullFloat32Field { @@ -384,6 +415,27 @@ func (t table) NullFloat64Field(name string) NullFloat64Field { return &nullfloat64Field{name: name, selection: t} } +func (s *selection) NullIntField(name string) NullIntField { + return &nullintField{name: name} +} +func (t table) NullIntField(name string) NullIntField { + return &nullintField{name: name, selection: t} +} + +func (s *selection) NullInt64Field(name string) NullInt64Field { + return &nullint64Field{name: name} +} +func (t table) NullInt64Field(name string) NullInt64Field { + return &nullint64Field{name: name, selection: t} +} + +func (s *selection) NullStringField(name string) NullStringField { + return &nullstringField{name: name} +} +func (t table) NullStringField(name string) NullStringField { + return &nullstringField{name: name, selection: t} +} + func (s *selection) NullTimeField(name string) NullTimeField { return &nulltimeField{name: name} } @@ -391,39 +443,473 @@ func (t table) NullTimeField(name string) NullTimeField { return &nulltimeField{name: name, selection: t} } +func (s *selection) StringField(name string) StringField { + return &stringField{name: name} +} +func (t table) StringField(name string) StringField { + return &stringField{name: name, selection: t} +} + +func (s *selection) TimeField(name string) TimeField { + return &timeField{name: name} +} +func (t table) TimeField(name string) TimeField { + return &timeField{name: name, selection: t} +} + ///// -type stringField struct { +type boolField struct { name string selection Selectable alias string fun FieldFunction } -type StringField interface { +type BoolField interface { TableField - Eq(value string) Condition - IsEq(value StringField) JoinCondition + Eq(value bool) Condition + IsEq(value BoolField) JoinCondition - Gt(value string) Condition - IsGt(value StringField) JoinCondition + Gt(value bool) Condition + IsGt(value BoolField) JoinCondition - Ge(value string) Condition - IsGe(value StringField) JoinCondition + Ge(value bool) Condition + IsGe(value BoolField) JoinCondition - Lt(value string) Condition - IsLt(value StringField) JoinCondition + Lt(value bool) Condition + IsLt(value BoolField) JoinCondition - Le(value string) Condition - IsLe(value StringField) JoinCondition + Le(value bool) Condition + IsLe(value BoolField) JoinCondition + +} + +func (c *boolField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *boolField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &boolField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &boolField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *boolField) As(alias string) Field { + return &boolField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *boolField) Alias() string { + return c.alias +} + +func (c *boolField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *boolField) Name() string { + return c.name +} + +func (c *boolField) Type() reflect.Type { + return typeBool +} + +func (c *boolField) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *boolField) Eq(pred bool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *boolField) IsEq(pred BoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *boolField) Gt(pred bool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *boolField) IsGt(pred BoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *boolField) Ge(pred bool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *boolField) IsGe(pred BoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *boolField) Lt(pred bool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *boolField) IsLt(pred BoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *boolField) Le(pred bool) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *boolField) IsLe(pred BoolField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func Bool(s Selectable, name string) BoolField { + return &boolField{name: name, selection: s} +} + +////// + + +func (c *boolField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *boolField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *boolField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *boolField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *boolField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *boolField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *boolField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *boolField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *boolField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + +func (c *boolField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *boolField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + + + + +type dateField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type DateField interface { + TableField + + Eq(value time.Time) Condition + IsEq(value DateField) JoinCondition + + Gt(value time.Time) Condition + IsGt(value DateField) JoinCondition + + Ge(value time.Time) Condition + IsGe(value DateField) JoinCondition + + Lt(value time.Time) Condition + IsLt(value DateField) JoinCondition + + Le(value time.Time) Condition + IsLe(value DateField) JoinCondition + +} + +func (c *dateField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *dateField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &dateField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &dateField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *dateField) As(alias string) Field { + return &dateField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *dateField) Alias() string { + return c.alias +} + +func (c *dateField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *dateField) Name() string { + return c.name +} + +func (c *dateField) Type() reflect.Type { + return typeDate +} + +func (c *dateField) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *dateField) Eq(pred time.Time) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *dateField) IsEq(pred DateField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *dateField) Gt(pred time.Time) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *dateField) IsGt(pred DateField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *dateField) Ge(pred time.Time) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *dateField) IsGe(pred DateField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *dateField) Lt(pred time.Time) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *dateField) IsLt(pred DateField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *dateField) Le(pred time.Time) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *dateField) IsLe(pred DateField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func Date(s Selectable, name string) DateField { + return &dateField{name: name, selection: s} +} + +////// + + +func (c *dateField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *dateField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *dateField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *dateField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *dateField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *dateField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *dateField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *dateField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *dateField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + +func (c *dateField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *dateField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + + + + +type datetimeField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type DatetimeField interface { + TableField + + Eq(value time.Time) Condition + IsEq(value DatetimeField) JoinCondition + + Gt(value time.Time) Condition + IsGt(value DatetimeField) JoinCondition + + Ge(value time.Time) Condition + IsGe(value DatetimeField) JoinCondition + + Lt(value time.Time) Condition + IsLt(value DatetimeField) JoinCondition + + Le(value time.Time) Condition + IsLe(value DatetimeField) JoinCondition } -func (c *stringField) Function() FieldFunction { +func (c *datetimeField) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -432,15 +918,15 @@ func (c *stringField) Function() FieldFunction { } } -func (c *stringField) fct(fun, expr string, args ...interface{}) Field { +func (c *datetimeField) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &stringField{ + return &datetimeField{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &stringField{ + return &datetimeField{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -458,8 +944,8 @@ func (c *stringField) fct(fun, expr string, args ...interface{}) Field { } } -func (c *stringField) As(alias string) Field { - return &stringField{ +func (c *datetimeField) As(alias string) Field { + return &datetimeField{ name: c.name, selection: c.selection, alias: alias, @@ -472,11 +958,11 @@ func (c *stringField) As(alias string) Field { } } -func (c *stringField) Alias() string { +func (c *datetimeField) Alias() string { return c.alias } -func (c *stringField) MaybeAlias() string { +func (c *datetimeField) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -484,15 +970,15 @@ func (c *stringField) MaybeAlias() string { } } -func (c *stringField) Name() string { +func (c *datetimeField) Name() string { return c.name } -func (c *stringField) Type() reflect.Type { - return typeString +func (c *datetimeField) Type() reflect.Type { + return typeDatetime } -func (c *stringField) Parent() Selectable { +func (c *datetimeField) Parent() Selectable { return c.selection } @@ -500,51 +986,51 @@ func (c *stringField) Parent() Selectable { -func (c *stringField) Eq(pred string) Condition { +func (c *datetimeField) Eq(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *stringField) IsEq(pred StringField) JoinCondition { +func (c *datetimeField) IsEq(pred DatetimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *stringField) Gt(pred string) Condition { +func (c *datetimeField) Gt(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *stringField) IsGt(pred StringField) JoinCondition { +func (c *datetimeField) IsGt(pred DatetimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *stringField) Ge(pred string) Condition { +func (c *datetimeField) Ge(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *stringField) IsGe(pred StringField) JoinCondition { +func (c *datetimeField) IsGe(pred DatetimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *stringField) Lt(pred string) Condition { +func (c *datetimeField) Lt(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *stringField) IsLt(pred StringField) JoinCondition { +func (c *datetimeField) IsLt(pred DatetimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *stringField) Le(pred string) Condition { +func (c *datetimeField) Le(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *stringField) IsLe(pred StringField) JoinCondition { +func (c *datetimeField) IsLe(pred DatetimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -552,88 +1038,88 @@ func (c *stringField) IsLe(pred StringField) JoinCondition { // -- -func String(s Selectable, name string) StringField { - return &stringField{name: name, selection: s} +func Datetime(s Selectable, name string) DatetimeField { + return &datetimeField{name: name, selection: s} } ////// -func (c *stringField) Avg() Field { +func (c *datetimeField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *stringField) Max() Field { +func (c *datetimeField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *stringField) Min() Field { +func (c *datetimeField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *stringField) Ceil() Field { +func (c *datetimeField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *stringField) Div(_0 interface{}) Field { +func (c *datetimeField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *stringField) Cast(_0 interface{}) Field { +func (c *datetimeField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *stringField) Md5() Field { +func (c *datetimeField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *stringField) Lower() Field { +func (c *datetimeField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *stringField) Hex() Field { +func (c *datetimeField) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *stringField) Substr2(_0 interface{}) Field { +func (c *datetimeField) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *stringField) Substr3(_0,_1 interface{}) Field { +func (c *datetimeField) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type boolField struct { +type float32Field struct { name string selection Selectable alias string fun FieldFunction } -type BoolField interface { +type Float32Field interface { TableField - Eq(value bool) Condition - IsEq(value BoolField) JoinCondition + Eq(value float32) Condition + IsEq(value Float32Field) JoinCondition - Gt(value bool) Condition - IsGt(value BoolField) JoinCondition + Gt(value float32) Condition + IsGt(value Float32Field) JoinCondition - Ge(value bool) Condition - IsGe(value BoolField) JoinCondition + Ge(value float32) Condition + IsGe(value Float32Field) JoinCondition - Lt(value bool) Condition - IsLt(value BoolField) JoinCondition + Lt(value float32) Condition + IsLt(value Float32Field) JoinCondition - Le(value bool) Condition - IsLe(value BoolField) JoinCondition + Le(value float32) Condition + IsLe(value Float32Field) JoinCondition } -func (c *boolField) Function() FieldFunction { +func (c *float32Field) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -642,15 +1128,15 @@ func (c *boolField) Function() FieldFunction { } } -func (c *boolField) fct(fun, expr string, args ...interface{}) Field { +func (c *float32Field) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &boolField{ + return &float32Field{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &boolField{ + return &float32Field{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -668,8 +1154,8 @@ func (c *boolField) fct(fun, expr string, args ...interface{}) Field { } } -func (c *boolField) As(alias string) Field { - return &boolField{ +func (c *float32Field) As(alias string) Field { + return &float32Field{ name: c.name, selection: c.selection, alias: alias, @@ -682,11 +1168,11 @@ func (c *boolField) As(alias string) Field { } } -func (c *boolField) Alias() string { +func (c *float32Field) Alias() string { return c.alias } -func (c *boolField) MaybeAlias() string { +func (c *float32Field) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -694,15 +1180,15 @@ func (c *boolField) MaybeAlias() string { } } -func (c *boolField) Name() string { +func (c *float32Field) Name() string { return c.name } -func (c *boolField) Type() reflect.Type { - return typeBool +func (c *float32Field) Type() reflect.Type { + return typeFloat32 } -func (c *boolField) Parent() Selectable { +func (c *float32Field) Parent() Selectable { return c.selection } @@ -710,51 +1196,51 @@ func (c *boolField) Parent() Selectable { -func (c *boolField) Eq(pred bool) Condition { +func (c *float32Field) Eq(pred float32) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *boolField) IsEq(pred BoolField) JoinCondition { +func (c *float32Field) IsEq(pred Float32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *boolField) Gt(pred bool) Condition { +func (c *float32Field) Gt(pred float32) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *boolField) IsGt(pred BoolField) JoinCondition { +func (c *float32Field) IsGt(pred Float32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *boolField) Ge(pred bool) Condition { +func (c *float32Field) Ge(pred float32) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *boolField) IsGe(pred BoolField) JoinCondition { +func (c *float32Field) IsGe(pred Float32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *boolField) Lt(pred bool) Condition { +func (c *float32Field) Lt(pred float32) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *boolField) IsLt(pred BoolField) JoinCondition { +func (c *float32Field) IsLt(pred Float32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *boolField) Le(pred bool) Condition { +func (c *float32Field) Le(pred float32) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *boolField) IsLe(pred BoolField) JoinCondition { +func (c *float32Field) IsLe(pred Float32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -762,88 +1248,88 @@ func (c *boolField) IsLe(pred BoolField) JoinCondition { // -- -func Bool(s Selectable, name string) BoolField { - return &boolField{name: name, selection: s} +func Float32(s Selectable, name string) Float32Field { + return &float32Field{name: name, selection: s} } ////// -func (c *boolField) Avg() Field { +func (c *float32Field) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *boolField) Max() Field { +func (c *float32Field) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *boolField) Min() Field { +func (c *float32Field) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *boolField) Ceil() Field { +func (c *float32Field) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *boolField) Div(_0 interface{}) Field { +func (c *float32Field) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *boolField) Cast(_0 interface{}) Field { +func (c *float32Field) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *boolField) Md5() Field { +func (c *float32Field) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *boolField) Lower() Field { +func (c *float32Field) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *boolField) Hex() Field { +func (c *float32Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *boolField) Substr2(_0 interface{}) Field { +func (c *float32Field) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *boolField) Substr3(_0,_1 interface{}) Field { +func (c *float32Field) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type intField struct { +type float64Field struct { name string selection Selectable alias string fun FieldFunction } -type IntField interface { +type Float64Field interface { TableField - Eq(value int) Condition - IsEq(value IntField) JoinCondition + Eq(value float64) Condition + IsEq(value Float64Field) JoinCondition - Gt(value int) Condition - IsGt(value IntField) JoinCondition + Gt(value float64) Condition + IsGt(value Float64Field) JoinCondition - Ge(value int) Condition - IsGe(value IntField) JoinCondition + Ge(value float64) Condition + IsGe(value Float64Field) JoinCondition - Lt(value int) Condition - IsLt(value IntField) JoinCondition + Lt(value float64) Condition + IsLt(value Float64Field) JoinCondition - Le(value int) Condition - IsLe(value IntField) JoinCondition + Le(value float64) Condition + IsLe(value Float64Field) JoinCondition } -func (c *intField) Function() FieldFunction { +func (c *float64Field) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -852,15 +1338,15 @@ func (c *intField) Function() FieldFunction { } } -func (c *intField) fct(fun, expr string, args ...interface{}) Field { +func (c *float64Field) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &intField{ + return &float64Field{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &intField{ + return &float64Field{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -878,8 +1364,8 @@ func (c *intField) fct(fun, expr string, args ...interface{}) Field { } } -func (c *intField) As(alias string) Field { - return &intField{ +func (c *float64Field) As(alias string) Field { + return &float64Field{ name: c.name, selection: c.selection, alias: alias, @@ -892,11 +1378,11 @@ func (c *intField) As(alias string) Field { } } -func (c *intField) Alias() string { +func (c *float64Field) Alias() string { return c.alias } -func (c *intField) MaybeAlias() string { +func (c *float64Field) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -904,15 +1390,15 @@ func (c *intField) MaybeAlias() string { } } -func (c *intField) Name() string { +func (c *float64Field) Name() string { return c.name } -func (c *intField) Type() reflect.Type { - return typeInt +func (c *float64Field) Type() reflect.Type { + return typeFloat64 } -func (c *intField) Parent() Selectable { +func (c *float64Field) Parent() Selectable { return c.selection } @@ -920,51 +1406,51 @@ func (c *intField) Parent() Selectable { -func (c *intField) Eq(pred int) Condition { +func (c *float64Field) Eq(pred float64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *intField) IsEq(pred IntField) JoinCondition { +func (c *float64Field) IsEq(pred Float64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *intField) Gt(pred int) Condition { +func (c *float64Field) Gt(pred float64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *intField) IsGt(pred IntField) JoinCondition { +func (c *float64Field) IsGt(pred Float64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *intField) Ge(pred int) Condition { +func (c *float64Field) Ge(pred float64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *intField) IsGe(pred IntField) JoinCondition { +func (c *float64Field) IsGe(pred Float64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *intField) Lt(pred int) Condition { +func (c *float64Field) Lt(pred float64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *intField) IsLt(pred IntField) JoinCondition { +func (c *float64Field) IsLt(pred Float64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *intField) Le(pred int) Condition { +func (c *float64Field) Le(pred float64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *intField) IsLe(pred IntField) JoinCondition { +func (c *float64Field) IsLe(pred Float64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -972,88 +1458,88 @@ func (c *intField) IsLe(pred IntField) JoinCondition { // -- -func Int(s Selectable, name string) IntField { - return &intField{name: name, selection: s} +func Float64(s Selectable, name string) Float64Field { + return &float64Field{name: name, selection: s} } ////// -func (c *intField) Avg() Field { +func (c *float64Field) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *intField) Max() Field { +func (c *float64Field) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *intField) Min() Field { +func (c *float64Field) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *intField) Ceil() Field { +func (c *float64Field) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *intField) Div(_0 interface{}) Field { +func (c *float64Field) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *intField) Cast(_0 interface{}) Field { +func (c *float64Field) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *intField) Md5() Field { +func (c *float64Field) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *intField) Lower() Field { +func (c *float64Field) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *intField) Hex() Field { +func (c *float64Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *intField) Substr2(_0 interface{}) Field { +func (c *float64Field) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *intField) Substr3(_0,_1 interface{}) Field { +func (c *float64Field) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type int64Field struct { +type intField struct { name string selection Selectable alias string fun FieldFunction } -type Int64Field interface { +type IntField interface { TableField - Eq(value int64) Condition - IsEq(value Int64Field) JoinCondition + Eq(value int) Condition + IsEq(value IntField) JoinCondition - Gt(value int64) Condition - IsGt(value Int64Field) JoinCondition + Gt(value int) Condition + IsGt(value IntField) JoinCondition - Ge(value int64) Condition - IsGe(value Int64Field) JoinCondition + Ge(value int) Condition + IsGe(value IntField) JoinCondition - Lt(value int64) Condition - IsLt(value Int64Field) JoinCondition + Lt(value int) Condition + IsLt(value IntField) JoinCondition - Le(value int64) Condition - IsLe(value Int64Field) JoinCondition + Le(value int) Condition + IsLe(value IntField) JoinCondition } -func (c *int64Field) Function() FieldFunction { +func (c *intField) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -1062,15 +1548,15 @@ func (c *int64Field) Function() FieldFunction { } } -func (c *int64Field) fct(fun, expr string, args ...interface{}) Field { +func (c *intField) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &int64Field{ + return &intField{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &int64Field{ + return &intField{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -1088,8 +1574,8 @@ func (c *int64Field) fct(fun, expr string, args ...interface{}) Field { } } -func (c *int64Field) As(alias string) Field { - return &int64Field{ +func (c *intField) As(alias string) Field { + return &intField{ name: c.name, selection: c.selection, alias: alias, @@ -1102,11 +1588,11 @@ func (c *int64Field) As(alias string) Field { } } -func (c *int64Field) Alias() string { +func (c *intField) Alias() string { return c.alias } -func (c *int64Field) MaybeAlias() string { +func (c *intField) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -1114,15 +1600,15 @@ func (c *int64Field) MaybeAlias() string { } } -func (c *int64Field) Name() string { +func (c *intField) Name() string { return c.name } -func (c *int64Field) Type() reflect.Type { - return typeInt64 +func (c *intField) Type() reflect.Type { + return typeInt } -func (c *int64Field) Parent() Selectable { +func (c *intField) Parent() Selectable { return c.selection } @@ -1130,51 +1616,51 @@ func (c *int64Field) Parent() Selectable { -func (c *int64Field) Eq(pred int64) Condition { +func (c *intField) Eq(pred int) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *int64Field) IsEq(pred Int64Field) JoinCondition { +func (c *intField) IsEq(pred IntField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *int64Field) Gt(pred int64) Condition { +func (c *intField) Gt(pred int) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *int64Field) IsGt(pred Int64Field) JoinCondition { +func (c *intField) IsGt(pred IntField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *int64Field) Ge(pred int64) Condition { +func (c *intField) Ge(pred int) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *int64Field) IsGe(pred Int64Field) JoinCondition { +func (c *intField) IsGe(pred IntField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *int64Field) Lt(pred int64) Condition { +func (c *intField) Lt(pred int) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *int64Field) IsLt(pred Int64Field) JoinCondition { +func (c *intField) IsLt(pred IntField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *int64Field) Le(pred int64) Condition { +func (c *intField) Le(pred int) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *int64Field) IsLe(pred Int64Field) JoinCondition { +func (c *intField) IsLe(pred IntField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -1182,88 +1668,88 @@ func (c *int64Field) IsLe(pred Int64Field) JoinCondition { // -- -func Int64(s Selectable, name string) Int64Field { - return &int64Field{name: name, selection: s} +func Int(s Selectable, name string) IntField { + return &intField{name: name, selection: s} } ////// -func (c *int64Field) Avg() Field { +func (c *intField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *int64Field) Max() Field { +func (c *intField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *int64Field) Min() Field { +func (c *intField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *int64Field) Ceil() Field { +func (c *intField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *int64Field) Div(_0 interface{}) Field { +func (c *intField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *int64Field) Cast(_0 interface{}) Field { +func (c *intField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *int64Field) Md5() Field { +func (c *intField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *int64Field) Lower() Field { +func (c *intField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *int64Field) Hex() Field { +func (c *intField) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *int64Field) Substr2(_0 interface{}) Field { +func (c *intField) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *int64Field) Substr3(_0,_1 interface{}) Field { +func (c *intField) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type float32Field struct { +type int64Field struct { name string selection Selectable alias string fun FieldFunction } -type Float32Field interface { +type Int64Field interface { TableField - Eq(value float32) Condition - IsEq(value Float32Field) JoinCondition + Eq(value int64) Condition + IsEq(value Int64Field) JoinCondition - Gt(value float32) Condition - IsGt(value Float32Field) JoinCondition + Gt(value int64) Condition + IsGt(value Int64Field) JoinCondition - Ge(value float32) Condition - IsGe(value Float32Field) JoinCondition + Ge(value int64) Condition + IsGe(value Int64Field) JoinCondition - Lt(value float32) Condition - IsLt(value Float32Field) JoinCondition + Lt(value int64) Condition + IsLt(value Int64Field) JoinCondition - Le(value float32) Condition - IsLe(value Float32Field) JoinCondition + Le(value int64) Condition + IsLe(value Int64Field) JoinCondition } -func (c *float32Field) Function() FieldFunction { +func (c *int64Field) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -1272,15 +1758,15 @@ func (c *float32Field) Function() FieldFunction { } } -func (c *float32Field) fct(fun, expr string, args ...interface{}) Field { +func (c *int64Field) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &float32Field{ + return &int64Field{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &float32Field{ + return &int64Field{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -1298,8 +1784,8 @@ func (c *float32Field) fct(fun, expr string, args ...interface{}) Field { } } -func (c *float32Field) As(alias string) Field { - return &float32Field{ +func (c *int64Field) As(alias string) Field { + return &int64Field{ name: c.name, selection: c.selection, alias: alias, @@ -1312,11 +1798,11 @@ func (c *float32Field) As(alias string) Field { } } -func (c *float32Field) Alias() string { +func (c *int64Field) Alias() string { return c.alias } -func (c *float32Field) MaybeAlias() string { +func (c *int64Field) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -1324,15 +1810,15 @@ func (c *float32Field) MaybeAlias() string { } } -func (c *float32Field) Name() string { +func (c *int64Field) Name() string { return c.name } -func (c *float32Field) Type() reflect.Type { - return typeFloat32 +func (c *int64Field) Type() reflect.Type { + return typeInt64 } -func (c *float32Field) Parent() Selectable { +func (c *int64Field) Parent() Selectable { return c.selection } @@ -1340,51 +1826,51 @@ func (c *float32Field) Parent() Selectable { -func (c *float32Field) Eq(pred float32) Condition { +func (c *int64Field) Eq(pred int64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *float32Field) IsEq(pred Float32Field) JoinCondition { +func (c *int64Field) IsEq(pred Int64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *float32Field) Gt(pred float32) Condition { +func (c *int64Field) Gt(pred int64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *float32Field) IsGt(pred Float32Field) JoinCondition { +func (c *int64Field) IsGt(pred Int64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *float32Field) Ge(pred float32) Condition { +func (c *int64Field) Ge(pred int64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *float32Field) IsGe(pred Float32Field) JoinCondition { +func (c *int64Field) IsGe(pred Int64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *float32Field) Lt(pred float32) Condition { +func (c *int64Field) Lt(pred int64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *float32Field) IsLt(pred Float32Field) JoinCondition { +func (c *int64Field) IsLt(pred Int64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *float32Field) Le(pred float32) Condition { +func (c *int64Field) Le(pred int64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *float32Field) IsLe(pred Float32Field) JoinCondition { +func (c *int64Field) IsLe(pred Int64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -1392,88 +1878,88 @@ func (c *float32Field) IsLe(pred Float32Field) JoinCondition { // -- -func Float32(s Selectable, name string) Float32Field { - return &float32Field{name: name, selection: s} +func Int64(s Selectable, name string) Int64Field { + return &int64Field{name: name, selection: s} } ////// -func (c *float32Field) Avg() Field { +func (c *int64Field) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *float32Field) Max() Field { +func (c *int64Field) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *float32Field) Min() Field { +func (c *int64Field) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *float32Field) Ceil() Field { +func (c *int64Field) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *float32Field) Div(_0 interface{}) Field { +func (c *int64Field) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *float32Field) Cast(_0 interface{}) Field { +func (c *int64Field) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *float32Field) Md5() Field { +func (c *int64Field) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *float32Field) Lower() Field { +func (c *int64Field) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *float32Field) Hex() Field { +func (c *int64Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *float32Field) Substr2(_0 interface{}) Field { +func (c *int64Field) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *float32Field) Substr3(_0,_1 interface{}) Field { +func (c *int64Field) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type float64Field struct { +type nullboolField struct { name string selection Selectable alias string fun FieldFunction } -type Float64Field interface { +type NullBoolField interface { TableField - Eq(value float64) Condition - IsEq(value Float64Field) JoinCondition + Eq(value sql.NullBool) Condition + IsEq(value NullBoolField) JoinCondition - Gt(value float64) Condition - IsGt(value Float64Field) JoinCondition + Gt(value sql.NullBool) Condition + IsGt(value NullBoolField) JoinCondition - Ge(value float64) Condition - IsGe(value Float64Field) JoinCondition + Ge(value sql.NullBool) Condition + IsGe(value NullBoolField) JoinCondition - Lt(value float64) Condition - IsLt(value Float64Field) JoinCondition + Lt(value sql.NullBool) Condition + IsLt(value NullBoolField) JoinCondition - Le(value float64) Condition - IsLe(value Float64Field) JoinCondition + Le(value sql.NullBool) Condition + IsLe(value NullBoolField) JoinCondition } -func (c *float64Field) Function() FieldFunction { +func (c *nullboolField) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -1482,15 +1968,15 @@ func (c *float64Field) Function() FieldFunction { } } -func (c *float64Field) fct(fun, expr string, args ...interface{}) Field { +func (c *nullboolField) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &float64Field{ + return &nullboolField{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &float64Field{ + return &nullboolField{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -1508,8 +1994,8 @@ func (c *float64Field) fct(fun, expr string, args ...interface{}) Field { } } -func (c *float64Field) As(alias string) Field { - return &float64Field{ +func (c *nullboolField) As(alias string) Field { + return &nullboolField{ name: c.name, selection: c.selection, alias: alias, @@ -1522,11 +2008,11 @@ func (c *float64Field) As(alias string) Field { } } -func (c *float64Field) Alias() string { +func (c *nullboolField) Alias() string { return c.alias } -func (c *float64Field) MaybeAlias() string { +func (c *nullboolField) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -1534,15 +2020,15 @@ func (c *float64Field) MaybeAlias() string { } } -func (c *float64Field) Name() string { +func (c *nullboolField) Name() string { return c.name } -func (c *float64Field) Type() reflect.Type { - return typeFloat64 +func (c *nullboolField) Type() reflect.Type { + return typeNullBool } -func (c *float64Field) Parent() Selectable { +func (c *nullboolField) Parent() Selectable { return c.selection } @@ -1550,51 +2036,51 @@ func (c *float64Field) Parent() Selectable { -func (c *float64Field) Eq(pred float64) Condition { +func (c *nullboolField) Eq(pred sql.NullBool) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *float64Field) IsEq(pred Float64Field) JoinCondition { +func (c *nullboolField) IsEq(pred NullBoolField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *float64Field) Gt(pred float64) Condition { +func (c *nullboolField) Gt(pred sql.NullBool) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *float64Field) IsGt(pred Float64Field) JoinCondition { +func (c *nullboolField) IsGt(pred NullBoolField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *float64Field) Ge(pred float64) Condition { +func (c *nullboolField) Ge(pred sql.NullBool) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *float64Field) IsGe(pred Float64Field) JoinCondition { +func (c *nullboolField) IsGe(pred NullBoolField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *float64Field) Lt(pred float64) Condition { +func (c *nullboolField) Lt(pred sql.NullBool) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *float64Field) IsLt(pred Float64Field) JoinCondition { +func (c *nullboolField) IsLt(pred NullBoolField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *float64Field) Le(pred float64) Condition { +func (c *nullboolField) Le(pred sql.NullBool) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *float64Field) IsLe(pred Float64Field) JoinCondition { +func (c *nullboolField) IsLe(pred NullBoolField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -1602,88 +2088,88 @@ func (c *float64Field) IsLe(pred Float64Field) JoinCondition { // -- -func Float64(s Selectable, name string) Float64Field { - return &float64Field{name: name, selection: s} +func NullBool(s Selectable, name string) NullBoolField { + return &nullboolField{name: name, selection: s} } ////// -func (c *float64Field) Avg() Field { +func (c *nullboolField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *float64Field) Max() Field { +func (c *nullboolField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *float64Field) Min() Field { +func (c *nullboolField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *float64Field) Ceil() Field { +func (c *nullboolField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *float64Field) Div(_0 interface{}) Field { +func (c *nullboolField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *float64Field) Cast(_0 interface{}) Field { +func (c *nullboolField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *float64Field) Md5() Field { +func (c *nullboolField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *float64Field) Lower() Field { +func (c *nullboolField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *float64Field) Hex() Field { +func (c *nullboolField) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *float64Field) Substr2(_0 interface{}) Field { +func (c *nullboolField) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *float64Field) Substr3(_0,_1 interface{}) Field { +func (c *nullboolField) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type timeField struct { +type nulldateField struct { name string selection Selectable alias string fun FieldFunction } -type TimeField interface { +type NullDateField interface { TableField - Eq(value time.Time) Condition - IsEq(value TimeField) JoinCondition + Eq(value NullableDate) Condition + IsEq(value NullDateField) JoinCondition - Gt(value time.Time) Condition - IsGt(value TimeField) JoinCondition + Gt(value NullableDate) Condition + IsGt(value NullDateField) JoinCondition - Ge(value time.Time) Condition - IsGe(value TimeField) JoinCondition + Ge(value NullableDate) Condition + IsGe(value NullDateField) JoinCondition - Lt(value time.Time) Condition - IsLt(value TimeField) JoinCondition + Lt(value NullableDate) Condition + IsLt(value NullDateField) JoinCondition - Le(value time.Time) Condition - IsLe(value TimeField) JoinCondition + Le(value NullableDate) Condition + IsLe(value NullDateField) JoinCondition } -func (c *timeField) Function() FieldFunction { +func (c *nulldateField) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -1692,15 +2178,15 @@ func (c *timeField) Function() FieldFunction { } } -func (c *timeField) fct(fun, expr string, args ...interface{}) Field { +func (c *nulldateField) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &timeField{ + return &nulldateField{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &timeField{ + return &nulldateField{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -1718,8 +2204,8 @@ func (c *timeField) fct(fun, expr string, args ...interface{}) Field { } } -func (c *timeField) As(alias string) Field { - return &timeField{ +func (c *nulldateField) As(alias string) Field { + return &nulldateField{ name: c.name, selection: c.selection, alias: alias, @@ -1732,11 +2218,11 @@ func (c *timeField) As(alias string) Field { } } -func (c *timeField) Alias() string { +func (c *nulldateField) Alias() string { return c.alias } -func (c *timeField) MaybeAlias() string { +func (c *nulldateField) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -1744,15 +2230,15 @@ func (c *timeField) MaybeAlias() string { } } -func (c *timeField) Name() string { +func (c *nulldateField) Name() string { return c.name } -func (c *timeField) Type() reflect.Type { - return typeTime +func (c *nulldateField) Type() reflect.Type { + return typeNullDate } -func (c *timeField) Parent() Selectable { +func (c *nulldateField) Parent() Selectable { return c.selection } @@ -1760,51 +2246,51 @@ func (c *timeField) Parent() Selectable { -func (c *timeField) Eq(pred time.Time) Condition { +func (c *nulldateField) Eq(pred NullableDate) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *timeField) IsEq(pred TimeField) JoinCondition { +func (c *nulldateField) IsEq(pred NullDateField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *timeField) Gt(pred time.Time) Condition { +func (c *nulldateField) Gt(pred NullableDate) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *timeField) IsGt(pred TimeField) JoinCondition { +func (c *nulldateField) IsGt(pred NullDateField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *timeField) Ge(pred time.Time) Condition { +func (c *nulldateField) Ge(pred NullableDate) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *timeField) IsGe(pred TimeField) JoinCondition { +func (c *nulldateField) IsGe(pred NullDateField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *timeField) Lt(pred time.Time) Condition { +func (c *nulldateField) Lt(pred NullableDate) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *timeField) IsLt(pred TimeField) JoinCondition { +func (c *nulldateField) IsLt(pred NullDateField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *timeField) Le(pred time.Time) Condition { +func (c *nulldateField) Le(pred NullableDate) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *timeField) IsLe(pred TimeField) JoinCondition { +func (c *nulldateField) IsLe(pred NullDateField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -1812,88 +2298,88 @@ func (c *timeField) IsLe(pred TimeField) JoinCondition { // -- -func Time(s Selectable, name string) TimeField { - return &timeField{name: name, selection: s} +func NullDate(s Selectable, name string) NullDateField { + return &nulldateField{name: name, selection: s} } ////// -func (c *timeField) Avg() Field { +func (c *nulldateField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *timeField) Max() Field { +func (c *nulldateField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *timeField) Min() Field { +func (c *nulldateField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *timeField) Ceil() Field { +func (c *nulldateField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *timeField) Div(_0 interface{}) Field { +func (c *nulldateField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *timeField) Cast(_0 interface{}) Field { +func (c *nulldateField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *timeField) Md5() Field { +func (c *nulldateField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *timeField) Lower() Field { +func (c *nulldateField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *timeField) Hex() Field { +func (c *nulldateField) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *timeField) Substr2(_0 interface{}) Field { +func (c *nulldateField) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *timeField) Substr3(_0,_1 interface{}) Field { +func (c *nulldateField) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type dateField struct { +type nulldatetimeField struct { name string selection Selectable alias string fun FieldFunction } -type DateField interface { +type NullDatetimeField interface { TableField - Eq(value time.Time) Condition - IsEq(value DateField) JoinCondition + Eq(value NullableDatetime) Condition + IsEq(value NullDatetimeField) JoinCondition - Gt(value time.Time) Condition - IsGt(value DateField) JoinCondition + Gt(value NullableDatetime) Condition + IsGt(value NullDatetimeField) JoinCondition - Ge(value time.Time) Condition - IsGe(value DateField) JoinCondition + Ge(value NullableDatetime) Condition + IsGe(value NullDatetimeField) JoinCondition - Lt(value time.Time) Condition - IsLt(value DateField) JoinCondition + Lt(value NullableDatetime) Condition + IsLt(value NullDatetimeField) JoinCondition - Le(value time.Time) Condition - IsLe(value DateField) JoinCondition + Le(value NullableDatetime) Condition + IsLe(value NullDatetimeField) JoinCondition } -func (c *dateField) Function() FieldFunction { +func (c *nulldatetimeField) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -1902,15 +2388,15 @@ func (c *dateField) Function() FieldFunction { } } -func (c *dateField) fct(fun, expr string, args ...interface{}) Field { +func (c *nulldatetimeField) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &dateField{ + return &nulldatetimeField{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &dateField{ + return &nulldatetimeField{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -1928,8 +2414,8 @@ func (c *dateField) fct(fun, expr string, args ...interface{}) Field { } } -func (c *dateField) As(alias string) Field { - return &dateField{ +func (c *nulldatetimeField) As(alias string) Field { + return &nulldatetimeField{ name: c.name, selection: c.selection, alias: alias, @@ -1942,11 +2428,11 @@ func (c *dateField) As(alias string) Field { } } -func (c *dateField) Alias() string { +func (c *nulldatetimeField) Alias() string { return c.alias } -func (c *dateField) MaybeAlias() string { +func (c *nulldatetimeField) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -1954,15 +2440,15 @@ func (c *dateField) MaybeAlias() string { } } -func (c *dateField) Name() string { +func (c *nulldatetimeField) Name() string { return c.name } -func (c *dateField) Type() reflect.Type { - return typeDate +func (c *nulldatetimeField) Type() reflect.Type { + return typeNullDatetime } -func (c *dateField) Parent() Selectable { +func (c *nulldatetimeField) Parent() Selectable { return c.selection } @@ -1970,51 +2456,51 @@ func (c *dateField) Parent() Selectable { -func (c *dateField) Eq(pred time.Time) Condition { +func (c *nulldatetimeField) Eq(pred NullableDatetime) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *dateField) IsEq(pred DateField) JoinCondition { +func (c *nulldatetimeField) IsEq(pred NullDatetimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *dateField) Gt(pred time.Time) Condition { +func (c *nulldatetimeField) Gt(pred NullableDatetime) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *dateField) IsGt(pred DateField) JoinCondition { +func (c *nulldatetimeField) IsGt(pred NullDatetimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *dateField) Ge(pred time.Time) Condition { +func (c *nulldatetimeField) Ge(pred NullableDatetime) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *dateField) IsGe(pred DateField) JoinCondition { +func (c *nulldatetimeField) IsGe(pred NullDatetimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *dateField) Lt(pred time.Time) Condition { +func (c *nulldatetimeField) Lt(pred NullableDatetime) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *dateField) IsLt(pred DateField) JoinCondition { +func (c *nulldatetimeField) IsLt(pred NullDatetimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *dateField) Le(pred time.Time) Condition { +func (c *nulldatetimeField) Le(pred NullableDatetime) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *dateField) IsLe(pred DateField) JoinCondition { +func (c *nulldatetimeField) IsLe(pred NullDatetimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -2022,88 +2508,88 @@ func (c *dateField) IsLe(pred DateField) JoinCondition { // -- -func Date(s Selectable, name string) DateField { - return &dateField{name: name, selection: s} +func NullDatetime(s Selectable, name string) NullDatetimeField { + return &nulldatetimeField{name: name, selection: s} } ////// -func (c *dateField) Avg() Field { +func (c *nulldatetimeField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *dateField) Max() Field { +func (c *nulldatetimeField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *dateField) Min() Field { +func (c *nulldatetimeField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *dateField) Ceil() Field { +func (c *nulldatetimeField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *dateField) Div(_0 interface{}) Field { +func (c *nulldatetimeField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *dateField) Cast(_0 interface{}) Field { +func (c *nulldatetimeField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *dateField) Md5() Field { +func (c *nulldatetimeField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *dateField) Lower() Field { +func (c *nulldatetimeField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *dateField) Hex() Field { +func (c *nulldatetimeField) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *dateField) Substr2(_0 interface{}) Field { +func (c *nulldatetimeField) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *dateField) Substr3(_0,_1 interface{}) Field { +func (c *nulldatetimeField) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type nullstringField struct { +type nullfloat32Field struct { name string selection Selectable alias string fun FieldFunction } -type NullStringField interface { +type NullFloat32Field interface { TableField - Eq(value sql.NullString) Condition - IsEq(value NullStringField) JoinCondition + Eq(value sql.NullFloat64) Condition + IsEq(value NullFloat32Field) JoinCondition - Gt(value sql.NullString) Condition - IsGt(value NullStringField) JoinCondition + Gt(value sql.NullFloat64) Condition + IsGt(value NullFloat32Field) JoinCondition - Ge(value sql.NullString) Condition - IsGe(value NullStringField) JoinCondition + Ge(value sql.NullFloat64) Condition + IsGe(value NullFloat32Field) JoinCondition - Lt(value sql.NullString) Condition - IsLt(value NullStringField) JoinCondition + Lt(value sql.NullFloat64) Condition + IsLt(value NullFloat32Field) JoinCondition - Le(value sql.NullString) Condition - IsLe(value NullStringField) JoinCondition + Le(value sql.NullFloat64) Condition + IsLe(value NullFloat32Field) JoinCondition } -func (c *nullstringField) Function() FieldFunction { +func (c *nullfloat32Field) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -2112,15 +2598,15 @@ func (c *nullstringField) Function() FieldFunction { } } -func (c *nullstringField) fct(fun, expr string, args ...interface{}) Field { +func (c *nullfloat32Field) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &nullstringField{ + return &nullfloat32Field{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &nullstringField{ + return &nullfloat32Field{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -2138,8 +2624,8 @@ func (c *nullstringField) fct(fun, expr string, args ...interface{}) Field { } } -func (c *nullstringField) As(alias string) Field { - return &nullstringField{ +func (c *nullfloat32Field) As(alias string) Field { + return &nullfloat32Field{ name: c.name, selection: c.selection, alias: alias, @@ -2152,11 +2638,11 @@ func (c *nullstringField) As(alias string) Field { } } -func (c *nullstringField) Alias() string { +func (c *nullfloat32Field) Alias() string { return c.alias } -func (c *nullstringField) MaybeAlias() string { +func (c *nullfloat32Field) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -2164,15 +2650,15 @@ func (c *nullstringField) MaybeAlias() string { } } -func (c *nullstringField) Name() string { +func (c *nullfloat32Field) Name() string { return c.name } -func (c *nullstringField) Type() reflect.Type { - return typeNullString +func (c *nullfloat32Field) Type() reflect.Type { + return typeNullFloat32 } -func (c *nullstringField) Parent() Selectable { +func (c *nullfloat32Field) Parent() Selectable { return c.selection } @@ -2180,51 +2666,51 @@ func (c *nullstringField) Parent() Selectable { -func (c *nullstringField) Eq(pred sql.NullString) Condition { +func (c *nullfloat32Field) Eq(pred sql.NullFloat64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *nullstringField) IsEq(pred NullStringField) JoinCondition { +func (c *nullfloat32Field) IsEq(pred NullFloat32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *nullstringField) Gt(pred sql.NullString) Condition { +func (c *nullfloat32Field) Gt(pred sql.NullFloat64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *nullstringField) IsGt(pred NullStringField) JoinCondition { +func (c *nullfloat32Field) IsGt(pred NullFloat32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *nullstringField) Ge(pred sql.NullString) Condition { +func (c *nullfloat32Field) Ge(pred sql.NullFloat64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *nullstringField) IsGe(pred NullStringField) JoinCondition { +func (c *nullfloat32Field) IsGe(pred NullFloat32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *nullstringField) Lt(pred sql.NullString) Condition { +func (c *nullfloat32Field) Lt(pred sql.NullFloat64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *nullstringField) IsLt(pred NullStringField) JoinCondition { +func (c *nullfloat32Field) IsLt(pred NullFloat32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *nullstringField) Le(pred sql.NullString) Condition { +func (c *nullfloat32Field) Le(pred sql.NullFloat64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *nullstringField) IsLe(pred NullStringField) JoinCondition { +func (c *nullfloat32Field) IsLe(pred NullFloat32Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -2232,88 +2718,88 @@ func (c *nullstringField) IsLe(pred NullStringField) JoinCondition { // -- -func NullString(s Selectable, name string) NullStringField { - return &nullstringField{name: name, selection: s} +func NullFloat32(s Selectable, name string) NullFloat32Field { + return &nullfloat32Field{name: name, selection: s} } ////// -func (c *nullstringField) Avg() Field { +func (c *nullfloat32Field) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *nullstringField) Max() Field { +func (c *nullfloat32Field) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *nullstringField) Min() Field { +func (c *nullfloat32Field) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *nullstringField) Ceil() Field { +func (c *nullfloat32Field) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *nullstringField) Div(_0 interface{}) Field { +func (c *nullfloat32Field) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *nullstringField) Cast(_0 interface{}) Field { +func (c *nullfloat32Field) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *nullstringField) Md5() Field { +func (c *nullfloat32Field) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *nullstringField) Lower() Field { +func (c *nullfloat32Field) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *nullstringField) Hex() Field { +func (c *nullfloat32Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *nullstringField) Substr2(_0 interface{}) Field { +func (c *nullfloat32Field) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *nullstringField) Substr3(_0,_1 interface{}) Field { +func (c *nullfloat32Field) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type nullboolField struct { +type nullfloat64Field struct { name string selection Selectable alias string fun FieldFunction } -type NullBoolField interface { +type NullFloat64Field interface { TableField - Eq(value sql.NullBool) Condition - IsEq(value NullBoolField) JoinCondition + Eq(value sql.NullFloat64) Condition + IsEq(value NullFloat64Field) JoinCondition - Gt(value sql.NullBool) Condition - IsGt(value NullBoolField) JoinCondition + Gt(value sql.NullFloat64) Condition + IsGt(value NullFloat64Field) JoinCondition - Ge(value sql.NullBool) Condition - IsGe(value NullBoolField) JoinCondition + Ge(value sql.NullFloat64) Condition + IsGe(value NullFloat64Field) JoinCondition - Lt(value sql.NullBool) Condition - IsLt(value NullBoolField) JoinCondition + Lt(value sql.NullFloat64) Condition + IsLt(value NullFloat64Field) JoinCondition - Le(value sql.NullBool) Condition - IsLe(value NullBoolField) JoinCondition + Le(value sql.NullFloat64) Condition + IsLe(value NullFloat64Field) JoinCondition } -func (c *nullboolField) Function() FieldFunction { +func (c *nullfloat64Field) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -2322,15 +2808,15 @@ func (c *nullboolField) Function() FieldFunction { } } -func (c *nullboolField) fct(fun, expr string, args ...interface{}) Field { +func (c *nullfloat64Field) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &nullboolField{ + return &nullfloat64Field{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &nullboolField{ + return &nullfloat64Field{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -2348,8 +2834,8 @@ func (c *nullboolField) fct(fun, expr string, args ...interface{}) Field { } } -func (c *nullboolField) As(alias string) Field { - return &nullboolField{ +func (c *nullfloat64Field) As(alias string) Field { + return &nullfloat64Field{ name: c.name, selection: c.selection, alias: alias, @@ -2362,11 +2848,11 @@ func (c *nullboolField) As(alias string) Field { } } -func (c *nullboolField) Alias() string { +func (c *nullfloat64Field) Alias() string { return c.alias } -func (c *nullboolField) MaybeAlias() string { +func (c *nullfloat64Field) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -2374,15 +2860,15 @@ func (c *nullboolField) MaybeAlias() string { } } -func (c *nullboolField) Name() string { +func (c *nullfloat64Field) Name() string { return c.name } -func (c *nullboolField) Type() reflect.Type { - return typeNullBool +func (c *nullfloat64Field) Type() reflect.Type { + return typeNullFloat64 } -func (c *nullboolField) Parent() Selectable { +func (c *nullfloat64Field) Parent() Selectable { return c.selection } @@ -2390,51 +2876,51 @@ func (c *nullboolField) Parent() Selectable { -func (c *nullboolField) Eq(pred sql.NullBool) Condition { +func (c *nullfloat64Field) Eq(pred sql.NullFloat64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *nullboolField) IsEq(pred NullBoolField) JoinCondition { +func (c *nullfloat64Field) IsEq(pred NullFloat64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *nullboolField) Gt(pred sql.NullBool) Condition { +func (c *nullfloat64Field) Gt(pred sql.NullFloat64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *nullboolField) IsGt(pred NullBoolField) JoinCondition { +func (c *nullfloat64Field) IsGt(pred NullFloat64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *nullboolField) Ge(pred sql.NullBool) Condition { +func (c *nullfloat64Field) Ge(pred sql.NullFloat64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *nullboolField) IsGe(pred NullBoolField) JoinCondition { +func (c *nullfloat64Field) IsGe(pred NullFloat64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *nullboolField) Lt(pred sql.NullBool) Condition { +func (c *nullfloat64Field) Lt(pred sql.NullFloat64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *nullboolField) IsLt(pred NullBoolField) JoinCondition { +func (c *nullfloat64Field) IsLt(pred NullFloat64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *nullboolField) Le(pred sql.NullBool) Condition { +func (c *nullfloat64Field) Le(pred sql.NullFloat64) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *nullboolField) IsLe(pred NullBoolField) JoinCondition { +func (c *nullfloat64Field) IsLe(pred NullFloat64Field) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -2442,54 +2928,54 @@ func (c *nullboolField) IsLe(pred NullBoolField) JoinCondition { // -- -func NullBool(s Selectable, name string) NullBoolField { - return &nullboolField{name: name, selection: s} +func NullFloat64(s Selectable, name string) NullFloat64Field { + return &nullfloat64Field{name: name, selection: s} } ////// -func (c *nullboolField) Avg() Field { +func (c *nullfloat64Field) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *nullboolField) Max() Field { +func (c *nullfloat64Field) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *nullboolField) Min() Field { +func (c *nullfloat64Field) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *nullboolField) Ceil() Field { +func (c *nullfloat64Field) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *nullboolField) Div(_0 interface{}) Field { +func (c *nullfloat64Field) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *nullboolField) Cast(_0 interface{}) Field { +func (c *nullfloat64Field) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *nullboolField) Md5() Field { +func (c *nullfloat64Field) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *nullboolField) Lower() Field { +func (c *nullfloat64Field) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *nullboolField) Hex() Field { +func (c *nullfloat64Field) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *nullboolField) Substr2(_0 interface{}) Field { +func (c *nullfloat64Field) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *nullboolField) Substr3(_0,_1 interface{}) Field { +func (c *nullfloat64Field) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } @@ -2916,34 +3402,244 @@ func (c *nullint64Field) Substr3(_0,_1 interface{}) Field { -type nullfloat32Field struct { +type nullstringField struct { name string selection Selectable alias string fun FieldFunction } -type NullFloat32Field interface { +type NullStringField interface { TableField - Eq(value sql.NullFloat64) Condition - IsEq(value NullFloat32Field) JoinCondition + Eq(value sql.NullString) Condition + IsEq(value NullStringField) JoinCondition - Gt(value sql.NullFloat64) Condition - IsGt(value NullFloat32Field) JoinCondition + Gt(value sql.NullString) Condition + IsGt(value NullStringField) JoinCondition - Ge(value sql.NullFloat64) Condition - IsGe(value NullFloat32Field) JoinCondition + Ge(value sql.NullString) Condition + IsGe(value NullStringField) JoinCondition - Lt(value sql.NullFloat64) Condition - IsLt(value NullFloat32Field) JoinCondition + Lt(value sql.NullString) Condition + IsLt(value NullStringField) JoinCondition - Le(value sql.NullFloat64) Condition - IsLe(value NullFloat32Field) JoinCondition + Le(value sql.NullString) Condition + IsLe(value NullStringField) JoinCondition } -func (c *nullfloat32Field) Function() FieldFunction { +func (c *nullstringField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *nullstringField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &nullstringField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &nullstringField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *nullstringField) As(alias string) Field { + return &nullstringField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *nullstringField) Alias() string { + return c.alias +} + +func (c *nullstringField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *nullstringField) Name() string { + return c.name +} + +func (c *nullstringField) Type() reflect.Type { + return typeNullString +} + +func (c *nullstringField) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *nullstringField) Eq(pred sql.NullString) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *nullstringField) IsEq(pred NullStringField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *nullstringField) Gt(pred sql.NullString) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *nullstringField) IsGt(pred NullStringField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *nullstringField) Ge(pred sql.NullString) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *nullstringField) IsGe(pred NullStringField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *nullstringField) Lt(pred sql.NullString) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *nullstringField) IsLt(pred NullStringField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *nullstringField) Le(pred sql.NullString) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *nullstringField) IsLe(pred NullStringField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func NullString(s Selectable, name string) NullStringField { + return &nullstringField{name: name, selection: s} +} + +////// + + +func (c *nullstringField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *nullstringField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *nullstringField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *nullstringField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *nullstringField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *nullstringField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *nullstringField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *nullstringField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *nullstringField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + +func (c *nullstringField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *nullstringField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + + + + +type nulltimeField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type NullTimeField interface { + TableField + + Eq(value NullableTime) Condition + IsEq(value NullTimeField) JoinCondition + + Gt(value NullableTime) Condition + IsGt(value NullTimeField) JoinCondition + + Ge(value NullableTime) Condition + IsGe(value NullTimeField) JoinCondition + + Lt(value NullableTime) Condition + IsLt(value NullTimeField) JoinCondition + + Le(value NullableTime) Condition + IsLe(value NullTimeField) JoinCondition + +} + +func (c *nulltimeField) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -2952,15 +3648,15 @@ func (c *nullfloat32Field) Function() FieldFunction { } } -func (c *nullfloat32Field) fct(fun, expr string, args ...interface{}) Field { +func (c *nulltimeField) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &nullfloat32Field{ + return &nulltimeField{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &nullfloat32Field{ + return &nulltimeField{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -2978,8 +3674,8 @@ func (c *nullfloat32Field) fct(fun, expr string, args ...interface{}) Field { } } -func (c *nullfloat32Field) As(alias string) Field { - return &nullfloat32Field{ +func (c *nulltimeField) As(alias string) Field { + return &nulltimeField{ name: c.name, selection: c.selection, alias: alias, @@ -2992,11 +3688,11 @@ func (c *nullfloat32Field) As(alias string) Field { } } -func (c *nullfloat32Field) Alias() string { +func (c *nulltimeField) Alias() string { return c.alias } -func (c *nullfloat32Field) MaybeAlias() string { +func (c *nulltimeField) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -3004,15 +3700,15 @@ func (c *nullfloat32Field) MaybeAlias() string { } } -func (c *nullfloat32Field) Name() string { +func (c *nulltimeField) Name() string { return c.name } -func (c *nullfloat32Field) Type() reflect.Type { - return typeNullFloat32 +func (c *nulltimeField) Type() reflect.Type { + return typeNullTime } -func (c *nullfloat32Field) Parent() Selectable { +func (c *nulltimeField) Parent() Selectable { return c.selection } @@ -3020,51 +3716,51 @@ func (c *nullfloat32Field) Parent() Selectable { -func (c *nullfloat32Field) Eq(pred sql.NullFloat64) Condition { +func (c *nulltimeField) Eq(pred NullableTime) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *nullfloat32Field) IsEq(pred NullFloat32Field) JoinCondition { +func (c *nulltimeField) IsEq(pred NullTimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *nullfloat32Field) Gt(pred sql.NullFloat64) Condition { +func (c *nulltimeField) Gt(pred NullableTime) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *nullfloat32Field) IsGt(pred NullFloat32Field) JoinCondition { +func (c *nulltimeField) IsGt(pred NullTimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *nullfloat32Field) Ge(pred sql.NullFloat64) Condition { +func (c *nulltimeField) Ge(pred NullableTime) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *nullfloat32Field) IsGe(pred NullFloat32Field) JoinCondition { +func (c *nulltimeField) IsGe(pred NullTimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *nullfloat32Field) Lt(pred sql.NullFloat64) Condition { +func (c *nulltimeField) Lt(pred NullableTime) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *nullfloat32Field) IsLt(pred NullFloat32Field) JoinCondition { +func (c *nulltimeField) IsLt(pred NullTimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *nullfloat32Field) Le(pred sql.NullFloat64) Condition { +func (c *nulltimeField) Le(pred NullableTime) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *nullfloat32Field) IsLe(pred NullFloat32Field) JoinCondition { +func (c *nulltimeField) IsLe(pred NullTimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -3072,88 +3768,88 @@ func (c *nullfloat32Field) IsLe(pred NullFloat32Field) JoinCondition { // -- -func NullFloat32(s Selectable, name string) NullFloat32Field { - return &nullfloat32Field{name: name, selection: s} +func NullTime(s Selectable, name string) NullTimeField { + return &nulltimeField{name: name, selection: s} } ////// -func (c *nullfloat32Field) Avg() Field { +func (c *nulltimeField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *nullfloat32Field) Max() Field { +func (c *nulltimeField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *nullfloat32Field) Min() Field { +func (c *nulltimeField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *nullfloat32Field) Ceil() Field { +func (c *nulltimeField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *nullfloat32Field) Div(_0 interface{}) Field { +func (c *nulltimeField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *nullfloat32Field) Cast(_0 interface{}) Field { +func (c *nulltimeField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *nullfloat32Field) Md5() Field { +func (c *nulltimeField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *nullfloat32Field) Lower() Field { +func (c *nulltimeField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *nullfloat32Field) Hex() Field { +func (c *nulltimeField) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *nullfloat32Field) Substr2(_0 interface{}) Field { +func (c *nulltimeField) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *nullfloat32Field) Substr3(_0,_1 interface{}) Field { +func (c *nulltimeField) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type nullfloat64Field struct { +type stringField struct { name string selection Selectable alias string fun FieldFunction } -type NullFloat64Field interface { +type StringField interface { TableField - Eq(value sql.NullFloat64) Condition - IsEq(value NullFloat64Field) JoinCondition + Eq(value string) Condition + IsEq(value StringField) JoinCondition - Gt(value sql.NullFloat64) Condition - IsGt(value NullFloat64Field) JoinCondition + Gt(value string) Condition + IsGt(value StringField) JoinCondition - Ge(value sql.NullFloat64) Condition - IsGe(value NullFloat64Field) JoinCondition + Ge(value string) Condition + IsGe(value StringField) JoinCondition - Lt(value sql.NullFloat64) Condition - IsLt(value NullFloat64Field) JoinCondition + Lt(value string) Condition + IsLt(value StringField) JoinCondition - Le(value sql.NullFloat64) Condition - IsLe(value NullFloat64Field) JoinCondition + Le(value string) Condition + IsLe(value StringField) JoinCondition } -func (c *nullfloat64Field) Function() FieldFunction { +func (c *stringField) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -3162,15 +3858,15 @@ func (c *nullfloat64Field) Function() FieldFunction { } } -func (c *nullfloat64Field) fct(fun, expr string, args ...interface{}) Field { +func (c *stringField) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &nullfloat64Field{ + return &stringField{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &nullfloat64Field{ + return &stringField{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -3188,8 +3884,8 @@ func (c *nullfloat64Field) fct(fun, expr string, args ...interface{}) Field { } } -func (c *nullfloat64Field) As(alias string) Field { - return &nullfloat64Field{ +func (c *stringField) As(alias string) Field { + return &stringField{ name: c.name, selection: c.selection, alias: alias, @@ -3202,11 +3898,11 @@ func (c *nullfloat64Field) As(alias string) Field { } } -func (c *nullfloat64Field) Alias() string { +func (c *stringField) Alias() string { return c.alias } -func (c *nullfloat64Field) MaybeAlias() string { +func (c *stringField) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -3214,15 +3910,15 @@ func (c *nullfloat64Field) MaybeAlias() string { } } -func (c *nullfloat64Field) Name() string { +func (c *stringField) Name() string { return c.name } -func (c *nullfloat64Field) Type() reflect.Type { - return typeNullFloat64 +func (c *stringField) Type() reflect.Type { + return typeString } -func (c *nullfloat64Field) Parent() Selectable { +func (c *stringField) Parent() Selectable { return c.selection } @@ -3230,51 +3926,51 @@ func (c *nullfloat64Field) Parent() Selectable { -func (c *nullfloat64Field) Eq(pred sql.NullFloat64) Condition { +func (c *stringField) Eq(pred string) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *nullfloat64Field) IsEq(pred NullFloat64Field) JoinCondition { +func (c *stringField) IsEq(pred StringField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *nullfloat64Field) Gt(pred sql.NullFloat64) Condition { +func (c *stringField) Gt(pred string) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *nullfloat64Field) IsGt(pred NullFloat64Field) JoinCondition { +func (c *stringField) IsGt(pred StringField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *nullfloat64Field) Ge(pred sql.NullFloat64) Condition { +func (c *stringField) Ge(pred string) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *nullfloat64Field) IsGe(pred NullFloat64Field) JoinCondition { +func (c *stringField) IsGe(pred StringField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *nullfloat64Field) Lt(pred sql.NullFloat64) Condition { +func (c *stringField) Lt(pred string) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *nullfloat64Field) IsLt(pred NullFloat64Field) JoinCondition { +func (c *stringField) IsLt(pred StringField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *nullfloat64Field) Le(pred sql.NullFloat64) Condition { +func (c *stringField) Le(pred string) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *nullfloat64Field) IsLe(pred NullFloat64Field) JoinCondition { +func (c *stringField) IsLe(pred StringField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -3282,88 +3978,88 @@ func (c *nullfloat64Field) IsLe(pred NullFloat64Field) JoinCondition { // -- -func NullFloat64(s Selectable, name string) NullFloat64Field { - return &nullfloat64Field{name: name, selection: s} +func String(s Selectable, name string) StringField { + return &stringField{name: name, selection: s} } ////// -func (c *nullfloat64Field) Avg() Field { +func (c *stringField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *nullfloat64Field) Max() Field { +func (c *stringField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *nullfloat64Field) Min() Field { +func (c *stringField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *nullfloat64Field) Ceil() Field { +func (c *stringField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *nullfloat64Field) Div(_0 interface{}) Field { +func (c *stringField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *nullfloat64Field) Cast(_0 interface{}) Field { +func (c *stringField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *nullfloat64Field) Md5() Field { +func (c *stringField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *nullfloat64Field) Lower() Field { +func (c *stringField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *nullfloat64Field) Hex() Field { +func (c *stringField) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *nullfloat64Field) Substr2(_0 interface{}) Field { +func (c *stringField) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *nullfloat64Field) Substr3(_0,_1 interface{}) Field { +func (c *stringField) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } -type nulltimeField struct { +type timeField struct { name string selection Selectable alias string fun FieldFunction } -type NullTimeField interface { +type TimeField interface { TableField - Eq(value NullableTime) Condition - IsEq(value NullTimeField) JoinCondition + Eq(value time.Time) Condition + IsEq(value TimeField) JoinCondition - Gt(value NullableTime) Condition - IsGt(value NullTimeField) JoinCondition + Gt(value time.Time) Condition + IsGt(value TimeField) JoinCondition - Ge(value NullableTime) Condition - IsGe(value NullTimeField) JoinCondition + Ge(value time.Time) Condition + IsGe(value TimeField) JoinCondition - Lt(value NullableTime) Condition - IsLt(value NullTimeField) JoinCondition + Lt(value time.Time) Condition + IsLt(value TimeField) JoinCondition - Le(value NullableTime) Condition - IsLe(value NullTimeField) JoinCondition + Le(value time.Time) Condition + IsLe(value TimeField) JoinCondition } -func (c *nulltimeField) Function() FieldFunction { +func (c *timeField) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -3372,15 +4068,15 @@ func (c *nulltimeField) Function() FieldFunction { } } -func (c *nulltimeField) fct(fun, expr string, args ...interface{}) Field { +func (c *timeField) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &nulltimeField{ + return &timeField{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &nulltimeField{ + return &timeField{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -3398,8 +4094,8 @@ func (c *nulltimeField) fct(fun, expr string, args ...interface{}) Field { } } -func (c *nulltimeField) As(alias string) Field { - return &nulltimeField{ +func (c *timeField) As(alias string) Field { + return &timeField{ name: c.name, selection: c.selection, alias: alias, @@ -3412,11 +4108,11 @@ func (c *nulltimeField) As(alias string) Field { } } -func (c *nulltimeField) Alias() string { +func (c *timeField) Alias() string { return c.alias } -func (c *nulltimeField) MaybeAlias() string { +func (c *timeField) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -3424,15 +4120,15 @@ func (c *nulltimeField) MaybeAlias() string { } } -func (c *nulltimeField) Name() string { +func (c *timeField) Name() string { return c.name } -func (c *nulltimeField) Type() reflect.Type { - return typeNullTime +func (c *timeField) Type() reflect.Type { + return typeTime } -func (c *nulltimeField) Parent() Selectable { +func (c *timeField) Parent() Selectable { return c.selection } @@ -3440,51 +4136,51 @@ func (c *nulltimeField) Parent() Selectable { -func (c *nulltimeField) Eq(pred NullableTime) Condition { +func (c *timeField) Eq(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *nulltimeField) IsEq(pred NullTimeField) JoinCondition { +func (c *timeField) IsEq(pred TimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *nulltimeField) Gt(pred NullableTime) Condition { +func (c *timeField) Gt(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *nulltimeField) IsGt(pred NullTimeField) JoinCondition { +func (c *timeField) IsGt(pred TimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *nulltimeField) Ge(pred NullableTime) Condition { +func (c *timeField) Ge(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *nulltimeField) IsGe(pred NullTimeField) JoinCondition { +func (c *timeField) IsGe(pred TimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *nulltimeField) Lt(pred NullableTime) Condition { +func (c *timeField) Lt(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *nulltimeField) IsLt(pred NullTimeField) JoinCondition { +func (c *timeField) IsLt(pred TimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *nulltimeField) Le(pred NullableTime) Condition { +func (c *timeField) Le(pred time.Time) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *nulltimeField) IsLe(pred NullTimeField) JoinCondition { +func (c *timeField) IsLe(pred TimeField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -3492,54 +4188,54 @@ func (c *nulltimeField) IsLe(pred NullTimeField) JoinCondition { // -- -func NullTime(s Selectable, name string) NullTimeField { - return &nulltimeField{name: name, selection: s} +func Time(s Selectable, name string) TimeField { + return &timeField{name: name, selection: s} } ////// -func (c *nulltimeField) Avg() Field { +func (c *timeField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *nulltimeField) Max() Field { +func (c *timeField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *nulltimeField) Min() Field { +func (c *timeField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *nulltimeField) Ceil() Field { +func (c *timeField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *nulltimeField) Div(_0 interface{}) Field { +func (c *timeField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *nulltimeField) Cast(_0 interface{}) Field { +func (c *timeField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *nulltimeField) Md5() Field { +func (c *timeField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *nulltimeField) Lower() Field { +func (c *timeField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *nulltimeField) Hex() Field { +func (c *timeField) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *nulltimeField) Substr2(_0 interface{}) Field { +func (c *timeField) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *nulltimeField) Substr3(_0,_1 interface{}) Field { +func (c *timeField) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } diff --git a/sqlc/schema.go b/sqlc/schema.go index da418b8..10b562d 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -31,102 +31,103 @@ func sqlc_tmpl_fields_tmpl() ([]byte, error) { 0x5f, 0x6f, 0xdb, 0x36, 0x10, 0x7f, 0xd7, 0xa7, 0x38, 0x18, 0x45, 0x20, 0x07, 0x8a, 0x12, 0x6c, 0x45, 0x1f, 0x0c, 0xe4, 0xc1, 0x69, 0x9c, 0xd5, 0x83, 0xeb, 0x04, 0xb1, 0xb2, 0x60, 0x4f, 0x03, 0x23, 0x53, 0x29, 0x37, - 0x95, 0xf2, 0x24, 0x3a, 0x4b, 0x61, 0xe8, 0xbb, 0xef, 0x8e, 0xa4, 0x64, - 0x4a, 0x96, 0x1c, 0x7b, 0xc3, 0x8a, 0xe5, 0xa1, 0x96, 0x8e, 0xf7, 0xe7, - 0x77, 0x77, 0xbf, 0x23, 0xa9, 0x9e, 0x9f, 0x43, 0xf4, 0x69, 0xba, 0x80, - 0x9b, 0xe9, 0x6c, 0x02, 0x8f, 0xe3, 0x05, 0x8c, 0x1f, 0xa2, 0xdb, 0x9f, - 0x26, 0xf3, 0xc9, 0xfd, 0x38, 0x9a, 0x5c, 0xc3, 0x19, 0x8c, 0xe7, 0xbf, - 0xc2, 0xe4, 0x7a, 0x1a, 0x2d, 0x20, 0xba, 0x35, 0xaa, 0x8f, 0xd3, 0xd9, - 0x0c, 0xae, 0x26, 0x30, 0xbb, 0x5d, 0x44, 0xf0, 0xf8, 0x69, 0x32, 0x87, - 0x69, 0x04, 0x28, 0xbf, 0x9f, 0xd4, 0x76, 0x9e, 0xb7, 0xd9, 0xc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39, 0xf4, 0xf4, 0xce, 0x69, 0x41, 0x1e, 0x02, 0x71, 0x0d, 0xa7, - 0x6b, 0x9d, 0xe9, 0xbf, 0x86, 0xb8, 0x53, 0x30, 0x17, 0xe2, 0xba, 0x0f, - 0xe2, 0x39, 0xfd, 0x59, 0x66, 0xdc, 0x9b, 0x71, 0xa0, 0xfe, 0x37, 0x78, - 0xf1, 0x46, 0x93, 0xbb, 0x20, 0xfa, 0x92, 0xe1, 0x38, 0x16, 0x7a, 0x6a, - 0x87, 0x9d, 0x1a, 0xde, 0x2e, 0x33, 0x6f, 0xec, 0x29, 0x83, 0x09, 0xf5, - 0x87, 0x4f, 0x28, 0xbc, 0x3d, 0x9a, 0xea, 0xf0, 0x49, 0x38, 0xa7, 0x78, - 0x86, 0x5e, 0x85, 0x78, 0x96, 0x22, 0x11, 0x3c, 0x27, 0x65, 0xaa, 0x4c, - 0x47, 0xbc, 0x03, 0x3a, 0x53, 0xc0, 0x69, 0xc1, 0xa9, 0x1e, 0x88, 0xa8, - 0x3b, 0x85, 0xb7, 0x93, 0x74, 0x5b, 0x70, 0x82, 0x0a, 0x2a, 0x9b, 0x65, - 0x7f, 0x11, 0xb0, 0xb6, 0xe2, 0x86, 0x5c, 0x8d, 0x80, 0xfe, 0x25, 0x7c, - 0x06, 0x81, 0x02, 0xdd, 0x8b, 0xef, 0x19, 0x3c, 0x80, 0x3a, 0xe7, 0x11, - 0xa8, 0xb2, 0x93, 0x2b, 0x7b, 0x6b, 0x67, 0x3a, 0xb9, 0x2f, 0x1a, 0x61, - 0x5e, 0xc7, 0x4a, 0xa3, 0x73, 0x72, 0xc0, 0xb7, 0x3a, 0x34, 0x8e, 0x42, - 0x45, 0x44, 0x14, 0xb3, 0x54, 0xb0, 0x62, 0xab, 0x85, 0xb5, 0x31, 0x1d, - 0xad, 0xe8, 0xe2, 0x39, 0x51, 0x77, 0xa3, 0x35, 0x37, 0xb8, 0xed, 0xe6, - 0xb6, 0xb3, 0x79, 0xad, 0x34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b7, 0x85, 0x41, 0xc3, + 0x72, 0x10, 0x80, 0x11, 0xd0, 0x76, 0x47, 0x02, 0x7c, 0x13, 0xd9, 0xef, + 0x94, 0xb8, 0xe5, 0xac, 0xf3, 0x85, 0x66, 0x1e, 0xff, 0x0e, 0x00, 0x00, + 0xff, 0xff, 0x1a, 0x58, 0xf9, 0x36, 0xfe, 0x13, 0x00, 0x00, }, "sqlc/tmpl/fields.tmpl", ) diff --git a/sqlc/sqlc.go b/sqlc/sqlc.go index a9fcdab..4332fe5 100644 --- a/sqlc/sqlc.go +++ b/sqlc/sqlc.go @@ -217,11 +217,21 @@ func Qualified(parts ...string) string { return strings.Join(tmp, ".") } +type NullableDate struct { + Date time.Time + Valid bool // Valid is true if Date is not NULL +} + type NullableTime struct { Time time.Time Valid bool // Valid is true if Time is not NULL } +type NullableDatetime struct { + Datetime time.Time + Valid bool // Valid is true if Datetime is not NULL +} + // Scan implements the Scanner interface. func (self *NullableTime) Scan(value interface{}) error { self.Time, self.Valid = value.(time.Time) diff --git a/sqlc/tmpl/fields.tmpl b/sqlc/tmpl/fields.tmpl index 8fdd1b6..a17ef68 100644 --- a/sqlc/tmpl/fields.tmpl +++ b/sqlc/tmpl/fields.tmpl @@ -13,11 +13,15 @@ import ( var ( typeBool = reflect.TypeOf(false) + typeDate = reflect.TypeOf(time.Unix(0, 0)) + typeDatetime = reflect.TypeOf(time.Unix(0, 0)) typeFloat32 = reflect.TypeOf(float32(0.)) typeFloat64 = reflect.TypeOf(float64(0.)) typeInt = reflect.TypeOf(int(0)) typeInt64 = reflect.TypeOf(int64(0)) typeNullBool = reflect.TypeOf(sql.NullBool{}) + typeNullDate = reflect.TypeOf(NullableDate{}) + typeNullDatetime = reflect.TypeOf(NullableDatetime{}) typeNullFloat32 = reflect.TypeOf(sql.NullFloat64{}) typeNullFloat64 = reflect.TypeOf(sql.NullFloat64{}) typeNullInt = reflect.TypeOf(sql.NullInt64{}) @@ -26,7 +30,6 @@ var ( typeNullTime = reflect.TypeOf(NullableTime{}) typeString = reflect.TypeOf("") typeTime = reflect.TypeOf(time.Unix(0, 0)) - typeDate = reflect.TypeOf(time.Unix(0, 0)) ) type InsertSetStep interface { From 6973d28b8e6fdf9087addb67d563f0c295880f0d Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Thu, 29 Jan 2015 12:38:01 -0500 Subject: [PATCH 10/17] generate time stuff --- sqlc/generator.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sqlc/generator.go b/sqlc/generator.go index c4dc776..d8f139e 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -21,8 +21,9 @@ var int_64 = regexp.MustCompile("INTEGER|BIGINT") var float_32 = regexp.MustCompile("FLOAT") var float_64 = regexp.MustCompile("DOUBLE PRECISION") var varchar = regexp.MustCompile("VARCHAR|CHARACTER VARYING|TEXT") -var ts = regexp.MustCompile("TIMESTAMP|DATETIME") +var datetime = regexp.MustCompile("TIMESTAMP|DATETIME") var date = regexp.MustCompile("DATE") +var time_ = regexp.MustCompile("TIME") var dbType = regexp.MustCompile("mysql|postgres|sqlite") type Provenance struct { @@ -188,10 +189,12 @@ func infoSchema(d Dialect, schema string, db *sql.DB) ([]TableMeta, error) { fieldType = "Float32" } else if varchar.MatchString(colType.String) { fieldType = "String" - } else if ts.MatchString(colType.String) { + } else if datetime.MatchString(colType.String) { fieldType = "Time" } else if date.MatchString(colType.String) { fieldType = "Date" + } else if time_.MatchString(colType.String) { + fieldType = "Time" } else if boolean.MatchString(colType.String) { fieldType = "Bool" } @@ -255,10 +258,12 @@ func sqlite(db *sql.DB) ([]TableMeta, error) { fieldType = "Float32" } else if varchar.MatchString(colType.String) { fieldType = "String" - } else if ts.MatchString(colType.String) { + } else if datetime.MatchString(colType.String) { fieldType = "Time" - } else if ts.MatchString(colType.String) { + } else if date.MatchString(colType.String) { fieldType = "Date" + } else if time_.MatchString(colType.String) { + fieldType = "Time" } else if boolean.MatchString(colType.String) { fieldType = "Bool" } From 54658d9bccfdbf80b4c429832d600a5f1d172545 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Thu, 29 Jan 2015 12:36:18 -0500 Subject: [PATCH 11/17] add numeric support --- sqlc/generator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlc/generator.go b/sqlc/generator.go index d8f139e..9a05652 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -19,7 +19,7 @@ var boolean = regexp.MustCompile("BOOLEAN") var integer = regexp.MustCompile("INT") var int_64 = regexp.MustCompile("INTEGER|BIGINT") var float_32 = regexp.MustCompile("FLOAT") -var float_64 = regexp.MustCompile("DOUBLE PRECISION") +var float_64 = regexp.MustCompile("DOUBLE PRECISION|NUMERIC") var varchar = regexp.MustCompile("VARCHAR|CHARACTER VARYING|TEXT") var datetime = regexp.MustCompile("TIMESTAMP|DATETIME") var date = regexp.MustCompile("DATE") From f276ff6bebbaecc30ae03588226ea507d2bee8db Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Thu, 29 Jan 2015 12:48:21 -0500 Subject: [PATCH 12/17] added inet support. this may not work. --- sqlc/fields.go | 2 + sqlc/generator.go | 5 ++ sqlc/schema.go | 196 +++++++++++++++++++++--------------------- sqlc/sqlc.go | 7 ++ sqlc/tmpl/fields.tmpl | 2 + 5 files changed, 115 insertions(+), 97 deletions(-) diff --git a/sqlc/fields.go b/sqlc/fields.go index 3db8eb9..5ccbbd3 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -18,12 +18,14 @@ var ( typeFloat32 = reflect.TypeOf(float32(0.)) typeFloat64 = reflect.TypeOf(float64(0.)) typeInt = reflect.TypeOf(int(0)) + typeInet = reflect.TypeOf(Inet{}) typeInt64 = reflect.TypeOf(int64(0)) typeNullBool = reflect.TypeOf(sql.NullBool{}) typeNullDate = reflect.TypeOf(NullableDate{}) typeNullDatetime = reflect.TypeOf(NullableDatetime{}) typeNullFloat32 = reflect.TypeOf(sql.NullFloat64{}) typeNullFloat64 = reflect.TypeOf(sql.NullFloat64{}) + typeNullInet = reflect.TypeOf(NullableInet{}) typeNullInt = reflect.TypeOf(sql.NullInt64{}) typeNullInt64 = reflect.TypeOf(sql.NullInt64{}) typeNullString = reflect.TypeOf(sql.NullString{}) diff --git a/sqlc/generator.go b/sqlc/generator.go index 9a05652..2f19128 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -24,6 +24,7 @@ var varchar = regexp.MustCompile("VARCHAR|CHARACTER VARYING|TEXT") var datetime = regexp.MustCompile("TIMESTAMP|DATETIME") var date = regexp.MustCompile("DATE") var time_ = regexp.MustCompile("TIME") +var inet = regexp.MustCompile("INET") var dbType = regexp.MustCompile("mysql|postgres|sqlite") type Provenance struct { @@ -197,6 +198,8 @@ func infoSchema(d Dialect, schema string, db *sql.DB) ([]TableMeta, error) { fieldType = "Time" } else if boolean.MatchString(colType.String) { fieldType = "Bool" + } else if inet.MatchString(colType.String) { + fieldType = "Inet" } if nullable { @@ -266,6 +269,8 @@ func sqlite(db *sql.DB) ([]TableMeta, error) { fieldType = "Time" } else if boolean.MatchString(colType.String) { fieldType = "Bool" + } else if inet.MatchString(colType.String) { + fieldType = "Inet" } if nullable { diff --git a/sqlc/schema.go b/sqlc/schema.go index 10b562d..06e31a2 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -30,104 +30,106 @@ func sqlc_tmpl_fields_tmpl() ([]byte, error) { 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0xcc, 0x58, 0x5f, 0x6f, 0xdb, 0x36, 0x10, 0x7f, 0xd7, 0xa7, 0x38, 0x18, 0x45, 0x20, 0x07, 0x8a, 0x12, 0x6c, 0x45, 0x1f, 0x0c, 0xe4, 0xc1, 0x69, 0x9c, 0xd5, - 0x83, 0xeb, 0x04, 0xb1, 0xb2, 0x60, 0x4f, 0x03, 0x23, 0x53, 0x29, 0x37, + 0x83, 0xeb, 0x04, 0xb1, 0xb2, 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 0x24, + 0x83, 0x94, 0x4d, 0xa0, 0x59, 0xa3, 0x64, 0x2a, 0xe5, 0x80, 0x1a, 0xac, + 0x02, 0x86, 0x77, 0xfa, 0xff, 0x01, 0x64, 0xbd, 0xde, 0xb4, 0x02, 0xa1, + 0x6f, 0x64, 0xba, 0x0f, 0x58, 0xd3, 0x01, 0x46, 0x17, 0xc4, 0x4d, 0xfd, + 0x8d, 0x1e, 0x38, 0xe9, 0x71, 0xde, 0xdb, 0x69, 0x56, 0x9c, 0x76, 0xbf, + 0x59, 0xf1, 0xda, 0x5d, 0x67, 0xc5, 0x6d, 0xf5, 0x9e, 0xfa, 0xab, 0xea, + 0x47, 0x93, 0xf7, 0x23, 0xba, 0x72, 0x5c, 0xfa, 0xe6, 0xfe, 0x63, 0xf6, + 0xde, 0xe1, 0x15, 0x53, 0xf5, 0x32, 0x4b, 0xb5, 0xaf, 0x50, 0x32, 0xde, + 0x48, 0xfd, 0x28, 0x89, 0x2c, 0x9c, 0x93, 0xd5, 0x5e, 0x46, 0x7b, 0xd9, + 0xec, 0x65, 0xb2, 0x8f, 0xc5, 0xea, 0xd8, 0x41, 0x1e, 0x13, 0x70, 0xdc, + 0x83, 0x14, 0x63, 0x26, 0x55, 0x49, 0x28, 0x93, 0x3a, 0xc2, 0xd7, 0xe7, + 0xf8, 0xdb, 0x13, 0x73, 0x38, 0xc4, 0xb9, 0xd7, 0xce, 0x68, 0xf0, 0x07, + 0x03, 0x7b, 0x88, 0x14, 0xd3, 0x3d, 0x13, 0x56, 0x83, 0x38, 0x2e, 0x29, + 0xe2, 0xb6, 0x27, 0x27, 0x19, 0xeb, 0x70, 0x4f, 0xf4, 0xb1, 0x81, 0x9e, + 0xcc, 0x6f, 0x0f, 0xd3, 0x1f, 0x9d, 0x64, 0xad, 0x23, 0xe2, 0x08, 0xe7, + 0x77, 0x71, 0xc1, 0xf0, 0x83, 0x7a, 0x68, 0x9c, 0xa0, 0x36, 0xd8, 0xa6, + 0xd7, 0x3c, 0x79, 0xa0, 0xc3, 0xd9, 0x59, 0xfb, 0x40, 0x6f, 0x9d, 0x83, + 0x87, 0x46, 0xee, 0x39, 0x2d, 0xc9, 0xcf, 0xbe, 0xc3, 0xd2, 0x44, 0xd7, + 0x08, 0xb7, 0x57, 0x1c, 0x9f, 0xf2, 0x67, 0xdd, 0xf4, 0xfa, 0x6d, 0xfb, + 0x0b, 0x9d, 0x9f, 0x23, 0x20, 0x97, 0x81, 0x5a, 0xc1, 0x76, 0xad, 0x02, + 0xb8, 0xab, 0xff, 0x9b, 0x66, 0xa4, 0x51, 0x34, 0x02, 0x8c, 0x75, 0x0c, + 0x7b, 0xee, 0x63, 0xdb, 0x48, 0x61, 0xef, 0xa9, 0x6d, 0xa6, 0x62, 0x2d, + 0x6c, 0x67, 0x5f, 0x70, 0xe4, 0x92, 0x00, 0xee, 0xe9, 0x57, 0xc1, 0x7f, + 0x1b, 0xb3, 0x75, 0xf1, 0x92, 0x75, 0x92, 0x59, 0xb4, 0x3f, 0x11, 0x4a, + 0xa3, 0xd4, 0x01, 0xfc, 0xf7, 0x97, 0xc2, 0xb2, 0xf2, 0xea, 0xab, 0x60, + 0xe7, 0x2e, 0xd8, 0xba, 0x9b, 0x1f, 0xc1, 0xfa, 0x01, 0x17, 0x78, 0xbb, + 0x8f, 0xe9, 0xb6, 0x30, 0xb0, 0x2c, 0x07, 0x01, 0x68, 0x01, 0x6d, 0x77, + 0x24, 0xc0, 0x37, 0x9e, 0xff, 0x4e, 0xc0, 0x0d, 0x67, 0x9d, 0x2f, 0x34, + 0xfd, 0xf8, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc5, 0x70, 0x22, 0xf5, + 0x52, 0x14, 0x00, 0x00, }, "sqlc/tmpl/fields.tmpl", ) diff --git a/sqlc/sqlc.go b/sqlc/sqlc.go index 4332fe5..7ea005d 100644 --- a/sqlc/sqlc.go +++ b/sqlc/sqlc.go @@ -217,6 +217,13 @@ func Qualified(parts ...string) string { return strings.Join(tmp, ".") } +type Inet []byte + +type NullableInet struct { + Inet Inet + Valid bool // Valid is true if Inet is not NULL +} + type NullableDate struct { Date time.Time Valid bool // Valid is true if Date is not NULL diff --git a/sqlc/tmpl/fields.tmpl b/sqlc/tmpl/fields.tmpl index a17ef68..e2781c0 100644 --- a/sqlc/tmpl/fields.tmpl +++ b/sqlc/tmpl/fields.tmpl @@ -18,12 +18,14 @@ var ( typeFloat32 = reflect.TypeOf(float32(0.)) typeFloat64 = reflect.TypeOf(float64(0.)) typeInt = reflect.TypeOf(int(0)) + typeInet = reflect.TypeOf(Inet{}) typeInt64 = reflect.TypeOf(int64(0)) typeNullBool = reflect.TypeOf(sql.NullBool{}) typeNullDate = reflect.TypeOf(NullableDate{}) typeNullDatetime = reflect.TypeOf(NullableDatetime{}) typeNullFloat32 = reflect.TypeOf(sql.NullFloat64{}) typeNullFloat64 = reflect.TypeOf(sql.NullFloat64{}) + typeNullInet = reflect.TypeOf(NullableInet{}) typeNullInt = reflect.TypeOf(sql.NullInt64{}) typeNullInt64 = reflect.TypeOf(sql.NullInt64{}) typeNullString = reflect.TypeOf(sql.NullString{}) From 4e8276d7146ad43705d01a0abe1169f6fbaa19b7 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Thu, 29 Jan 2015 15:10:46 -0500 Subject: [PATCH 13/17] forgot some nullable time methods --- sqlc/sqlc.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/sqlc/sqlc.go b/sqlc/sqlc.go index 7ea005d..c8934ec 100644 --- a/sqlc/sqlc.go +++ b/sqlc/sqlc.go @@ -224,31 +224,73 @@ type NullableInet struct { Valid bool // Valid is true if Inet is not NULL } +// Scan implements the Scanner interface. +func (self *NullableInet) Scan(value interface{}) error { + self.Inet, self.Valid = value.([]byte) + return nil +} + +// Value implements the driver Valuer interface. +func (self NullableInet) Value() (driver.Value, error) { + if !self.Valid { + return nil, nil + } + return self.Inet, nil +} + type NullableDate struct { Date time.Time Valid bool // Valid is true if Date is not NULL } +// Scan implements the Scanner interface. +func (self *NullableDate) Scan(value interface{}) error { + self.Date, self.Valid = value.(time.Time) + return nil +} + +// Value implements the driver Valuer interface. +func (self NullableDate) Value() (driver.Value, error) { + if !self.Valid { + return nil, nil + } + return self.Date, nil +} + type NullableTime struct { Time time.Time Valid bool // Valid is true if Time is not NULL } +// Scan implements the Scanner interface. +func (self *NullableTime) Scan(value interface{}) error { + self.Time, self.Valid = value.(time.Time) + return nil +} + +// Value implements the driver Valuer interface. +func (self NullableTime) Value() (driver.Value, error) { + if !self.Valid { + return nil, nil + } + return self.Time, nil +} + type NullableDatetime struct { Datetime time.Time Valid bool // Valid is true if Datetime is not NULL } // Scan implements the Scanner interface. -func (self *NullableTime) Scan(value interface{}) error { - self.Time, self.Valid = value.(time.Time) +func (self *NullableDatetime) Scan(value interface{}) error { + self.Datetime, self.Valid = value.(time.Time) return nil } // Value implements the driver Valuer interface. -func (self NullableTime) Value() (driver.Value, error) { +func (self NullableDatetime) Value() (driver.Value, error) { if !self.Valid { return nil, nil } - return self.Time, nil + return self.Datetime, nil } From 3369adb5e7bfbcb7ed445b834968bf0de3dcfcce Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Thu, 29 Jan 2015 15:58:46 -0500 Subject: [PATCH 14/17] make inet type compile --- meta/types.go | 2 + sqlc/fields.go | 464 +++++++++++++++++++++++++++++++++++++++++- sqlc/schema.go | 204 +++++++++---------- sqlc/sqlc.go | 4 +- sqlc/tmpl/fields.tmpl | 2 +- 5 files changed, 569 insertions(+), 107 deletions(-) diff --git a/meta/types.go b/meta/types.go index 2ffa697..97314f3 100644 --- a/meta/types.go +++ b/meta/types.go @@ -16,6 +16,7 @@ var Types = []TypeInfo{ TypeInfo{Prefix: "Datetime", Literal: "time.Time"}, // TODO(shutej): test TypeInfo{Prefix: "Float32", Literal: "float32"}, TypeInfo{Prefix: "Float64", Literal: "float64"}, + TypeInfo{Prefix: "Inet", Literal: "[]byte"}, // TODO(shutej): test TypeInfo{Prefix: "Int", Literal: "int"}, TypeInfo{Prefix: "Int64", Literal: "int64"}, TypeInfo{Prefix: "NullBool", Literal: "sql.NullBool"}, @@ -23,6 +24,7 @@ var Types = []TypeInfo{ TypeInfo{Prefix: "NullDatetime", Literal: "NullableDatetime"}, // TODO(shutej): test TypeInfo{Prefix: "NullFloat32", Literal: "sql.NullFloat64"}, // TODO(shutej): test TypeInfo{Prefix: "NullFloat64", Literal: "sql.NullFloat64"}, + TypeInfo{Prefix: "NullInet", Literal: "NullableInet"}, // TODO(shutej): test TypeInfo{Prefix: "NullInt", Literal: "sql.NullInt64"}, // TODO(shutej): test TypeInfo{Prefix: "NullInt64", Literal: "sql.NullInt64"}, TypeInfo{Prefix: "NullString", Literal: "sql.NullString"}, diff --git a/sqlc/fields.go b/sqlc/fields.go index 5ccbbd3..26e23d2 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -18,7 +18,7 @@ var ( typeFloat32 = reflect.TypeOf(float32(0.)) typeFloat64 = reflect.TypeOf(float64(0.)) typeInt = reflect.TypeOf(int(0)) - typeInet = reflect.TypeOf(Inet{}) + typeInet = reflect.TypeOf([]byte{}) typeInt64 = reflect.TypeOf(int64(0)) typeNullBool = reflect.TypeOf(sql.NullBool{}) typeNullDate = reflect.TypeOf(NullableDate{}) @@ -47,6 +47,8 @@ type InsertSetStep interface { SetFloat64(Float64Field, float64) InsertSetMoreStep + SetInet(InetField, []byte) InsertSetMoreStep + SetInt(IntField, int) InsertSetMoreStep SetInt64(Int64Field, int64) InsertSetMoreStep @@ -61,6 +63,8 @@ type InsertSetStep interface { SetNullFloat64(NullFloat64Field, sql.NullFloat64) InsertSetMoreStep + SetNullInet(NullInetField, NullableInet) InsertSetMoreStep + SetNullInt(NullIntField, sql.NullInt64) InsertSetMoreStep SetNullInt64(NullInt64Field, sql.NullInt64) InsertSetMoreStep @@ -88,6 +92,8 @@ type UpdateSetStep interface { SetFloat64(Float64Field, float64) UpdateSetMoreStep + SetInet(InetField, []byte) UpdateSetMoreStep + SetInt(IntField, int) UpdateSetMoreStep SetInt64(Int64Field, int64) UpdateSetMoreStep @@ -102,6 +108,8 @@ type UpdateSetStep interface { SetNullFloat64(NullFloat64Field, sql.NullFloat64) UpdateSetMoreStep + SetNullInet(NullInetField, NullableInet) UpdateSetMoreStep + SetNullInt(NullIntField, sql.NullInt64) UpdateSetMoreStep SetNullInt64(NullInt64Field, sql.NullInt64) UpdateSetMoreStep @@ -137,6 +145,10 @@ func (i *insert) SetFloat64(f Float64Field, v float64) InsertSetMoreStep { return i.Set(f, v) } +func (i *insert) SetInet(f InetField, v []byte) InsertSetMoreStep { + return i.Set(f, v) +} + func (i *insert) SetInt(f IntField, v int) InsertSetMoreStep { return i.Set(f, v) } @@ -165,6 +177,10 @@ func (i *insert) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) InsertSet return i.Set(f, v) } +func (i *insert) SetNullInet(f NullInetField, v NullableInet) InsertSetMoreStep { + return i.Set(f, v) +} + func (i *insert) SetNullInt(f NullIntField, v sql.NullInt64) InsertSetMoreStep { return i.Set(f, v) } @@ -211,6 +227,10 @@ func (u *update) SetFloat64(f Float64Field, v float64) UpdateSetMoreStep { return u.Set(f, v) } +func (u *update) SetInet(f InetField, v []byte) UpdateSetMoreStep { + return u.Set(f, v) +} + func (u *update) SetInt(f IntField, v int) UpdateSetMoreStep { return u.Set(f, v) } @@ -239,6 +259,10 @@ func (u *update) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) UpdateSet return u.Set(f, v) } +func (u *update) SetNullInet(f NullInetField, v NullableInet) UpdateSetMoreStep { + return u.Set(f, v) +} + func (u *update) SetNullInt(f NullIntField, v sql.NullInt64) UpdateSetMoreStep { return u.Set(f, v) } @@ -278,6 +302,8 @@ type Reflectable interface { Float64Field(name string) Float64Field + InetField(name string) InetField + IntField(name string) IntField Int64Field(name string) Int64Field @@ -292,6 +318,8 @@ type Reflectable interface { NullFloat64Field(name string) NullFloat64Field + NullInetField(name string) NullInetField + NullIntField(name string) NullIntField NullInt64Field(name string) NullInt64Field @@ -368,6 +396,13 @@ func (t table) Float64Field(name string) Float64Field { return &float64Field{name: name, selection: t} } +func (s *selection) InetField(name string) InetField { + return &inetField{name: name} +} +func (t table) InetField(name string) InetField { + return &inetField{name: name, selection: t} +} + func (s *selection) IntField(name string) IntField { return &intField{name: name} } @@ -417,6 +452,13 @@ func (t table) NullFloat64Field(name string) NullFloat64Field { return &nullfloat64Field{name: name, selection: t} } +func (s *selection) NullInetField(name string) NullInetField { + return &nullinetField{name: name} +} +func (t table) NullInetField(name string) NullInetField { + return &nullinetField{name: name, selection: t} +} + func (s *selection) NullIntField(name string) NullIntField { return &nullintField{name: name} } @@ -1514,6 +1556,216 @@ func (c *float64Field) Substr3(_0,_1 interface{}) Field { +type inetField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type InetField interface { + TableField + + Eq(value []byte) Condition + IsEq(value InetField) JoinCondition + + Gt(value []byte) Condition + IsGt(value InetField) JoinCondition + + Ge(value []byte) Condition + IsGe(value InetField) JoinCondition + + Lt(value []byte) Condition + IsLt(value InetField) JoinCondition + + Le(value []byte) Condition + IsLe(value InetField) JoinCondition + +} + +func (c *inetField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *inetField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &inetField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &inetField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *inetField) As(alias string) Field { + return &inetField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *inetField) Alias() string { + return c.alias +} + +func (c *inetField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *inetField) Name() string { + return c.name +} + +func (c *inetField) Type() reflect.Type { + return typeInet +} + +func (c *inetField) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *inetField) Eq(pred []byte) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *inetField) IsEq(pred InetField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *inetField) Gt(pred []byte) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *inetField) IsGt(pred InetField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *inetField) Ge(pred []byte) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *inetField) IsGe(pred InetField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *inetField) Lt(pred []byte) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *inetField) IsLt(pred InetField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *inetField) Le(pred []byte) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *inetField) IsLe(pred InetField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func Inet(s Selectable, name string) InetField { + return &inetField{name: name, selection: s} +} + +////// + + +func (c *inetField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *inetField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *inetField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *inetField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *inetField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *inetField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *inetField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *inetField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *inetField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + +func (c *inetField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *inetField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + + + + type intField struct { name string selection Selectable @@ -2984,6 +3236,216 @@ func (c *nullfloat64Field) Substr3(_0,_1 interface{}) Field { +type nullinetField struct { + name string + selection Selectable + alias string + fun FieldFunction +} + +type NullInetField interface { + TableField + + Eq(value NullableInet) Condition + IsEq(value NullInetField) JoinCondition + + Gt(value NullableInet) Condition + IsGt(value NullInetField) JoinCondition + + Ge(value NullableInet) Condition + IsGe(value NullInetField) JoinCondition + + Lt(value NullableInet) Condition + IsLt(value NullInetField) JoinCondition + + Le(value NullableInet) Condition + IsLe(value NullInetField) JoinCondition + +} + +func (c *nullinetField) Function() FieldFunction { + return FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + } +} + +func (c *nullinetField) fct(fun, expr string, args ...interface{}) Field { + if &c.fun == nil { + return &nullinetField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{Name:fun, Expr:expr, Args: args}, + } + } else { + return &nullinetField{ + name: c.name, + selection: c.selection, + fun: FieldFunction{ + Name: fun, + Expr: expr, + Args: args, + Child: &FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + }, + } + } +} + +func (c *nullinetField) As(alias string) Field { + return &nullinetField{ + name: c.name, + selection: c.selection, + alias: alias, + fun: FieldFunction{ + Name: c.fun.Name, + Expr: c.fun.Expr, + Args: c.fun.Args, + Child: c.fun.Child, + }, + } +} + +func (c *nullinetField) Alias() string { + return c.alias +} + +func (c *nullinetField) MaybeAlias() string { + if c.alias == "" { + return c.name + } else { + return c.alias + } +} + +func (c *nullinetField) Name() string { + return c.name +} + +func (c *nullinetField) Type() reflect.Type { + return typeNullInet +} + +func (c *nullinetField) Parent() Selectable { + return c.selection +} + +// -- + + + +func (c *nullinetField) Eq(pred NullableInet) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} +} + +func (c *nullinetField) IsEq(pred NullInetField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} +} + + + +func (c *nullinetField) Gt(pred NullableInet) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} +} + +func (c *nullinetField) IsGt(pred NullInetField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} +} + + + +func (c *nullinetField) Ge(pred NullableInet) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} +} + +func (c *nullinetField) IsGe(pred NullInetField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} +} + + + +func (c *nullinetField) Lt(pred NullableInet) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} +} + +func (c *nullinetField) IsLt(pred NullInetField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} +} + + + +func (c *nullinetField) Le(pred NullableInet) Condition { + return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} +} + +func (c *nullinetField) IsLe(pred NullInetField) JoinCondition { + return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} +} + + + +// -- + +func NullInet(s Selectable, name string) NullInetField { + return &nullinetField{name: name, selection: s} +} + +////// + + +func (c *nullinetField) Avg() Field { + return c.fct("Avg", "AVG(%s)") +} + +func (c *nullinetField) Max() Field { + return c.fct("Max", "MAX(%s)") +} + +func (c *nullinetField) Min() Field { + return c.fct("Min", "MIN(%s)") +} + +func (c *nullinetField) Ceil() Field { + return c.fct("Ceil", "CEIL(%s)") +} + +func (c *nullinetField) Div(_0 interface{}) Field { + return c.fct("Div", "%s / %v", _0) +} + +func (c *nullinetField) Cast(_0 interface{}) Field { + return c.fct("Cast", "CAST(%s AS %s)", _0) +} + +func (c *nullinetField) Md5() Field { + return c.fct("Md5", "MD5(%s)") +} + +func (c *nullinetField) Lower() Field { + return c.fct("Lower", "LOWER(%s)") +} + +func (c *nullinetField) Hex() Field { + return c.fct("Hex", "HEX(%s)") +} + +func (c *nullinetField) Substr2(_0 interface{}) Field { + return c.fct("Substr2", "SUBSTR(%s, %v)", _0) +} + +func (c *nullinetField) Substr3(_0,_1 interface{}) Field { + return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) +} + + + + type nullintField struct { name string selection Selectable diff --git a/sqlc/schema.go b/sqlc/schema.go index 06e31a2..213b82c 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -28,108 +28,108 @@ func bindata_read(data []byte, name string) ([]byte, error) { func sqlc_tmpl_fields_tmpl() ([]byte, error) { return bindata_read([]byte{ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0xcc, 0x58, - 0x5f, 0x6f, 0xdb, 0x36, 0x10, 0x7f, 0xd7, 0xa7, 0x38, 0x18, 0x45, 0x20, - 0x07, 0x8a, 0x12, 0x6c, 0x45, 0x1f, 0x0c, 0xe4, 0xc1, 0x69, 0x9c, 0xd5, - 0x83, 0xeb, 0x04, 0xb1, 0xb2, 0x60, 0x4f, 0x83, 0x22, 0x53, 0x29, 0x37, - 0x55, 0xf6, 0x24, 0x3a, 0x4b, 0x61, 0xe8, 0xbb, 0xef, 0x8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 0x0e, 0x30, 0x97, 0xd5, 0x87, 0x84, 0xae, 0xb4, 0x72, 0x8e, - 0x02, 0x29, 0x9e, 0xbc, 0xae, 0x8b, 0x46, 0x4c, 0x2f, 0x4a, 0x3c, 0x2e, - 0x9e, 0xcb, 0x46, 0x4c, 0x2f, 0x4a, 0xfc, 0xf1, 0x0b, 0xcf, 0x96, 0x23, - 0x2d, 0x96, 0x2f, 0x24, 0x3f, 0x06, 0x7d, 0x9a, 0xe0, 0x06, 0xb5, 0xc9, - 0x03, 0x60, 0x18, 0x4b, 0x97, 0x3b, 0x80, 0x18, 0x23, 0x40, 0x18, 0x86, - 0xd6, 0x49, 0xb4, 0x6b, 0x6f, 0x9e, 0xc2, 0x89, 0x8c, 0x09, 0x97, 0x97, - 0x90, 0xf3, 0x0c, 0x54, 0x4a, 0x07, 0x75, 0xbd, 0xd4, 0x54, 0x3d, 0x38, - 0x52, 0x8f, 0x49, 0x98, 0x37, 0xe9, 0x83, 0x39, 0x09, 0x49, 0xd8, 0xbc, - 0xd4, 0xab, 0x18, 0x53, 0x5b, 0xb5, 0x38, 0x95, 0x74, 0xca, 0x44, 0x24, - 0x83, 0x94, 0x4d, 0xa0, 0x59, 0xa3, 0x64, 0x2a, 0xe5, 0x80, 0x1a, 0xac, - 0x02, 0x86, 0x77, 0xfa, 0xff, 0x01, 0x64, 0xbd, 0xde, 0xb4, 0x02, 0xa1, - 0x6f, 0x64, 0xba, 0x0f, 0x58, 0xd3, 0x01, 0x46, 0x17, 0xc4, 0x4d, 0xfd, - 0x8d, 0x1e, 0x38, 0xe9, 0x71, 0xde, 0xdb, 0x69, 0x56, 0x9c, 0x76, 0xbf, - 0x59, 0xf1, 0xda, 0x5d, 0x67, 0xc5, 0x6d, 0xf5, 0x9e, 0xfa, 0xab, 0xea, - 0x47, 0x93, 0xf7, 0x23, 0xba, 0x72, 0x5c, 0xfa, 0xe6, 0xfe, 0x63, 0xf6, - 0xde, 0xe1, 0x15, 0x53, 0xf5, 0x32, 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0x20, 0xba, 0xd6, 0xaa, 0xf7, 0xd3, + 0xd9, 0x0c, 0x2e, 0x26, 0x30, 0xbb, 0x5e, 0x44, 0x70, 0xff, 0x69, 0x32, + 0x87, 0x69, 0x04, 0x28, 0xbf, 0x9d, 0xd4, 0x76, 0x9e, 0xb7, 0xdd, 0xc2, + 0x9b, 0x75, 0xce, 0x97, 0x05, 0x8c, 0xce, 0x21, 0xa4, 0x27, 0x11, 0x33, + 0xc9, 0x0b, 0x28, 0x4b, 0xb5, 0x96, 0x6c, 0xb2, 0x58, 0xaf, 0xd1, 0x93, + 0x14, 0xab, 0x4c, 0x2d, 0x79, 0x6b, 0x16, 0xff, 0xc1, 0x1e, 0x39, 0x14, + 0x7f, 0xa6, 0xb1, 0xe7, 0x89, 0xaf, 0xeb, 0x55, 0x2e, 0xc1, 0xf7, 0x00, + 0x06, 0x4b, 0x26, 0xd9, 0x03, 0x2b, 0xf8, 0x29, 0x2e, 0x0d, 0x48, 0x90, + 0xf3, 0x24, 0xe5, 0xb1, 0x54, 0xcf, 0x52, 0x7c, 0xe5, 0x03, 0x6f, 0xe8, + 0x79, 0x4f, 0x2c, 0x57, 0xea, 0xf2, 0x65, 0xcd, 0x2f, 0x56, 0xab, 0x14, + 0xce, 0xc1, 0xe8, 0x85, 0x11, 0x8a, 0xae, 0x13, 0x3f, 0x61, 0x69, 0xc1, + 0x87, 0x46, 0xe5, 0x12, 0x31, 0x75, 0x55, 0xc8, 0x5b, 0x78, 0x97, 0x89, + 0x67, 0xff, 0x2c, 0x80, 0xb3, 0xa1, 0xad, 0x4c, 0x4b, 0x07, 0x1b, 0x5c, + 0xa5, 0x2b, 0x26, 0xbf, 0xff, 0xce, 0x81, 0x41, 0x2f, 0xf8, 0x67, 0x61, + 0x53, 0xf7, 0xc3, 0xfb, 0x1e, 0xdd, 0x0f, 0xef, 0x6d, 0xdd, 0x69, 0x26, + 0xbb, 0x7a, 0x22, 0x93, 0xfe, 0x99, 0xa5, 0xc2, 0x1d, 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0xbb, 0x23, 0x01, 0xbe, 0x89, 0xec, 0x77, 0x02, + 0x6e, 0x39, 0xeb, 0x7c, 0xa1, 0x99, 0xc7, 0xbf, 0x03, 0x00, 0x00, 0xff, + 0xff, 0x65, 0x52, 0xe3, 0x3c, 0x54, 0x14, 0x00, 0x00, }, "sqlc/tmpl/fields.tmpl", ) diff --git a/sqlc/sqlc.go b/sqlc/sqlc.go index c8934ec..1226cfd 100644 --- a/sqlc/sqlc.go +++ b/sqlc/sqlc.go @@ -217,10 +217,8 @@ func Qualified(parts ...string) string { return strings.Join(tmp, ".") } -type Inet []byte - type NullableInet struct { - Inet Inet + Inet []byte Valid bool // Valid is true if Inet is not NULL } diff --git a/sqlc/tmpl/fields.tmpl b/sqlc/tmpl/fields.tmpl index e2781c0..74e9ff0 100644 --- a/sqlc/tmpl/fields.tmpl +++ b/sqlc/tmpl/fields.tmpl @@ -18,7 +18,7 @@ var ( typeFloat32 = reflect.TypeOf(float32(0.)) typeFloat64 = reflect.TypeOf(float64(0.)) typeInt = reflect.TypeOf(int(0)) - typeInet = reflect.TypeOf(Inet{}) + typeInet = reflect.TypeOf([]byte{}) typeInt64 = reflect.TypeOf(int64(0)) typeNullBool = reflect.TypeOf(sql.NullBool{}) typeNullDate = reflect.TypeOf(NullableDate{}) From 3d35d3afbf242a207d068889ab990b5495ef42f1 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Tue, 3 Mar 2015 18:36:11 -0500 Subject: [PATCH 15/17] fix time->datetime --- sqlc/generator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlc/generator.go b/sqlc/generator.go index 2f19128..7a5fe8f 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -191,7 +191,7 @@ func infoSchema(d Dialect, schema string, db *sql.DB) ([]TableMeta, error) { } else if varchar.MatchString(colType.String) { fieldType = "String" } else if datetime.MatchString(colType.String) { - fieldType = "Time" + fieldType = "Datetime" } else if date.MatchString(colType.String) { fieldType = "Date" } else if time_.MatchString(colType.String) { From f2ec7ee949e48dbea6eec326b01db8d7f76248f4 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Sun, 15 Mar 2015 13:33:02 -0400 Subject: [PATCH 16/17] substitute inet with blob --- meta/types.go | 4 +- sqlc/fields.go | 218 +++++++++++++++++++++--------------------- sqlc/generator.go | 12 +-- sqlc/schema.go | 204 +++++++++++++++++++-------------------- sqlc/sqlc.go | 6 +- sqlc/tmpl/fields.tmpl | 4 +- 6 files changed, 224 insertions(+), 224 deletions(-) diff --git a/meta/types.go b/meta/types.go index 97314f3..311b343 100644 --- a/meta/types.go +++ b/meta/types.go @@ -16,7 +16,7 @@ var Types = []TypeInfo{ TypeInfo{Prefix: "Datetime", Literal: "time.Time"}, // TODO(shutej): test TypeInfo{Prefix: "Float32", Literal: "float32"}, TypeInfo{Prefix: "Float64", Literal: "float64"}, - TypeInfo{Prefix: "Inet", Literal: "[]byte"}, // TODO(shutej): test + TypeInfo{Prefix: "Blob", Literal: "[]byte"}, // TODO(shutej): test TypeInfo{Prefix: "Int", Literal: "int"}, TypeInfo{Prefix: "Int64", Literal: "int64"}, TypeInfo{Prefix: "NullBool", Literal: "sql.NullBool"}, @@ -24,7 +24,7 @@ var Types = []TypeInfo{ TypeInfo{Prefix: "NullDatetime", Literal: "NullableDatetime"}, // TODO(shutej): test TypeInfo{Prefix: "NullFloat32", Literal: "sql.NullFloat64"}, // TODO(shutej): test TypeInfo{Prefix: "NullFloat64", Literal: "sql.NullFloat64"}, - TypeInfo{Prefix: "NullInet", Literal: "NullableInet"}, // TODO(shutej): test + TypeInfo{Prefix: "NullBlob", Literal: "NullableBlob"}, // TODO(shutej): test TypeInfo{Prefix: "NullInt", Literal: "sql.NullInt64"}, // TODO(shutej): test TypeInfo{Prefix: "NullInt64", Literal: "sql.NullInt64"}, TypeInfo{Prefix: "NullString", Literal: "sql.NullString"}, diff --git a/sqlc/fields.go b/sqlc/fields.go index 26e23d2..4830510 100755 --- a/sqlc/fields.go +++ b/sqlc/fields.go @@ -18,14 +18,14 @@ var ( typeFloat32 = reflect.TypeOf(float32(0.)) typeFloat64 = reflect.TypeOf(float64(0.)) typeInt = reflect.TypeOf(int(0)) - typeInet = reflect.TypeOf([]byte{}) + typeBlob = reflect.TypeOf([]byte{}) typeInt64 = reflect.TypeOf(int64(0)) typeNullBool = reflect.TypeOf(sql.NullBool{}) typeNullDate = reflect.TypeOf(NullableDate{}) typeNullDatetime = reflect.TypeOf(NullableDatetime{}) typeNullFloat32 = reflect.TypeOf(sql.NullFloat64{}) typeNullFloat64 = reflect.TypeOf(sql.NullFloat64{}) - typeNullInet = reflect.TypeOf(NullableInet{}) + typeNullBlob = reflect.TypeOf(NullableBlob{}) typeNullInt = reflect.TypeOf(sql.NullInt64{}) typeNullInt64 = reflect.TypeOf(sql.NullInt64{}) typeNullString = reflect.TypeOf(sql.NullString{}) @@ -47,7 +47,7 @@ type InsertSetStep interface { SetFloat64(Float64Field, float64) InsertSetMoreStep - SetInet(InetField, []byte) InsertSetMoreStep + SetBlob(BlobField, []byte) InsertSetMoreStep SetInt(IntField, int) InsertSetMoreStep @@ -63,7 +63,7 @@ type InsertSetStep interface { SetNullFloat64(NullFloat64Field, sql.NullFloat64) InsertSetMoreStep - SetNullInet(NullInetField, NullableInet) InsertSetMoreStep + SetNullBlob(NullBlobField, NullableBlob) InsertSetMoreStep SetNullInt(NullIntField, sql.NullInt64) InsertSetMoreStep @@ -92,7 +92,7 @@ type UpdateSetStep interface { SetFloat64(Float64Field, float64) UpdateSetMoreStep - SetInet(InetField, []byte) UpdateSetMoreStep + SetBlob(BlobField, []byte) UpdateSetMoreStep SetInt(IntField, int) UpdateSetMoreStep @@ -108,7 +108,7 @@ type UpdateSetStep interface { SetNullFloat64(NullFloat64Field, sql.NullFloat64) UpdateSetMoreStep - SetNullInet(NullInetField, NullableInet) UpdateSetMoreStep + SetNullBlob(NullBlobField, NullableBlob) UpdateSetMoreStep SetNullInt(NullIntField, sql.NullInt64) UpdateSetMoreStep @@ -145,7 +145,7 @@ func (i *insert) SetFloat64(f Float64Field, v float64) InsertSetMoreStep { return i.Set(f, v) } -func (i *insert) SetInet(f InetField, v []byte) InsertSetMoreStep { +func (i *insert) SetBlob(f BlobField, v []byte) InsertSetMoreStep { return i.Set(f, v) } @@ -177,7 +177,7 @@ func (i *insert) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) InsertSet return i.Set(f, v) } -func (i *insert) SetNullInet(f NullInetField, v NullableInet) InsertSetMoreStep { +func (i *insert) SetNullBlob(f NullBlobField, v NullableBlob) InsertSetMoreStep { return i.Set(f, v) } @@ -227,7 +227,7 @@ func (u *update) SetFloat64(f Float64Field, v float64) UpdateSetMoreStep { return u.Set(f, v) } -func (u *update) SetInet(f InetField, v []byte) UpdateSetMoreStep { +func (u *update) SetBlob(f BlobField, v []byte) UpdateSetMoreStep { return u.Set(f, v) } @@ -259,7 +259,7 @@ func (u *update) SetNullFloat64(f NullFloat64Field, v sql.NullFloat64) UpdateSet return u.Set(f, v) } -func (u *update) SetNullInet(f NullInetField, v NullableInet) UpdateSetMoreStep { +func (u *update) SetNullBlob(f NullBlobField, v NullableBlob) UpdateSetMoreStep { return u.Set(f, v) } @@ -302,7 +302,7 @@ type Reflectable interface { Float64Field(name string) Float64Field - InetField(name string) InetField + BlobField(name string) BlobField IntField(name string) IntField @@ -318,7 +318,7 @@ type Reflectable interface { NullFloat64Field(name string) NullFloat64Field - NullInetField(name string) NullInetField + NullBlobField(name string) NullBlobField NullIntField(name string) NullIntField @@ -396,11 +396,11 @@ func (t table) Float64Field(name string) Float64Field { return &float64Field{name: name, selection: t} } -func (s *selection) InetField(name string) InetField { - return &inetField{name: name} +func (s *selection) BlobField(name string) BlobField { + return &blobField{name: name} } -func (t table) InetField(name string) InetField { - return &inetField{name: name, selection: t} +func (t table) BlobField(name string) BlobField { + return &blobField{name: name, selection: t} } func (s *selection) IntField(name string) IntField { @@ -452,11 +452,11 @@ func (t table) NullFloat64Field(name string) NullFloat64Field { return &nullfloat64Field{name: name, selection: t} } -func (s *selection) NullInetField(name string) NullInetField { - return &nullinetField{name: name} +func (s *selection) NullBlobField(name string) NullBlobField { + return &nullblobField{name: name} } -func (t table) NullInetField(name string) NullInetField { - return &nullinetField{name: name, selection: t} +func (t table) NullBlobField(name string) NullBlobField { + return &nullblobField{name: name, selection: t} } func (s *selection) NullIntField(name string) NullIntField { @@ -1556,34 +1556,34 @@ func (c *float64Field) Substr3(_0,_1 interface{}) Field { -type inetField struct { +type blobField struct { name string selection Selectable alias string fun FieldFunction } -type InetField interface { +type BlobField interface { TableField Eq(value []byte) Condition - IsEq(value InetField) JoinCondition + IsEq(value BlobField) JoinCondition Gt(value []byte) Condition - IsGt(value InetField) JoinCondition + IsGt(value BlobField) JoinCondition Ge(value []byte) Condition - IsGe(value InetField) JoinCondition + IsGe(value BlobField) JoinCondition Lt(value []byte) Condition - IsLt(value InetField) JoinCondition + IsLt(value BlobField) JoinCondition Le(value []byte) Condition - IsLe(value InetField) JoinCondition + IsLe(value BlobField) JoinCondition } -func (c *inetField) Function() FieldFunction { +func (c *blobField) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -1592,15 +1592,15 @@ func (c *inetField) Function() FieldFunction { } } -func (c *inetField) fct(fun, expr string, args ...interface{}) Field { +func (c *blobField) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &inetField{ + return &blobField{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &inetField{ + return &blobField{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -1618,8 +1618,8 @@ func (c *inetField) fct(fun, expr string, args ...interface{}) Field { } } -func (c *inetField) As(alias string) Field { - return &inetField{ +func (c *blobField) As(alias string) Field { + return &blobField{ name: c.name, selection: c.selection, alias: alias, @@ -1632,11 +1632,11 @@ func (c *inetField) As(alias string) Field { } } -func (c *inetField) Alias() string { +func (c *blobField) Alias() string { return c.alias } -func (c *inetField) MaybeAlias() string { +func (c *blobField) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -1644,15 +1644,15 @@ func (c *inetField) MaybeAlias() string { } } -func (c *inetField) Name() string { +func (c *blobField) Name() string { return c.name } -func (c *inetField) Type() reflect.Type { - return typeInet +func (c *blobField) Type() reflect.Type { + return typeBlob } -func (c *inetField) Parent() Selectable { +func (c *blobField) Parent() Selectable { return c.selection } @@ -1660,51 +1660,51 @@ func (c *inetField) Parent() Selectable { -func (c *inetField) Eq(pred []byte) Condition { +func (c *blobField) Eq(pred []byte) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *inetField) IsEq(pred InetField) JoinCondition { +func (c *blobField) IsEq(pred BlobField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *inetField) Gt(pred []byte) Condition { +func (c *blobField) Gt(pred []byte) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *inetField) IsGt(pred InetField) JoinCondition { +func (c *blobField) IsGt(pred BlobField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *inetField) Ge(pred []byte) Condition { +func (c *blobField) Ge(pred []byte) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *inetField) IsGe(pred InetField) JoinCondition { +func (c *blobField) IsGe(pred BlobField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *inetField) Lt(pred []byte) Condition { +func (c *blobField) Lt(pred []byte) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *inetField) IsLt(pred InetField) JoinCondition { +func (c *blobField) IsLt(pred BlobField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *inetField) Le(pred []byte) Condition { +func (c *blobField) Le(pred []byte) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *inetField) IsLe(pred InetField) JoinCondition { +func (c *blobField) IsLe(pred BlobField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -1712,54 +1712,54 @@ func (c *inetField) IsLe(pred InetField) JoinCondition { // -- -func Inet(s Selectable, name string) InetField { - return &inetField{name: name, selection: s} +func Blob(s Selectable, name string) BlobField { + return &blobField{name: name, selection: s} } ////// -func (c *inetField) Avg() Field { +func (c *blobField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *inetField) Max() Field { +func (c *blobField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *inetField) Min() Field { +func (c *blobField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *inetField) Ceil() Field { +func (c *blobField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *inetField) Div(_0 interface{}) Field { +func (c *blobField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *inetField) Cast(_0 interface{}) Field { +func (c *blobField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *inetField) Md5() Field { +func (c *blobField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *inetField) Lower() Field { +func (c *blobField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *inetField) Hex() Field { +func (c *blobField) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *inetField) Substr2(_0 interface{}) Field { +func (c *blobField) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *inetField) Substr3(_0,_1 interface{}) Field { +func (c *blobField) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } @@ -3236,34 +3236,34 @@ func (c *nullfloat64Field) Substr3(_0,_1 interface{}) Field { -type nullinetField struct { +type nullblobField struct { name string selection Selectable alias string fun FieldFunction } -type NullInetField interface { +type NullBlobField interface { TableField - Eq(value NullableInet) Condition - IsEq(value NullInetField) JoinCondition + Eq(value NullableBlob) Condition + IsEq(value NullBlobField) JoinCondition - Gt(value NullableInet) Condition - IsGt(value NullInetField) JoinCondition + Gt(value NullableBlob) Condition + IsGt(value NullBlobField) JoinCondition - Ge(value NullableInet) Condition - IsGe(value NullInetField) JoinCondition + Ge(value NullableBlob) Condition + IsGe(value NullBlobField) JoinCondition - Lt(value NullableInet) Condition - IsLt(value NullInetField) JoinCondition + Lt(value NullableBlob) Condition + IsLt(value NullBlobField) JoinCondition - Le(value NullableInet) Condition - IsLe(value NullInetField) JoinCondition + Le(value NullableBlob) Condition + IsLe(value NullBlobField) JoinCondition } -func (c *nullinetField) Function() FieldFunction { +func (c *nullblobField) Function() FieldFunction { return FieldFunction{ Name: c.fun.Name, Expr: c.fun.Expr, @@ -3272,15 +3272,15 @@ func (c *nullinetField) Function() FieldFunction { } } -func (c *nullinetField) fct(fun, expr string, args ...interface{}) Field { +func (c *nullblobField) fct(fun, expr string, args ...interface{}) Field { if &c.fun == nil { - return &nullinetField{ + return &nullblobField{ name: c.name, selection: c.selection, fun: FieldFunction{Name:fun, Expr:expr, Args: args}, } } else { - return &nullinetField{ + return &nullblobField{ name: c.name, selection: c.selection, fun: FieldFunction{ @@ -3298,8 +3298,8 @@ func (c *nullinetField) fct(fun, expr string, args ...interface{}) Field { } } -func (c *nullinetField) As(alias string) Field { - return &nullinetField{ +func (c *nullblobField) As(alias string) Field { + return &nullblobField{ name: c.name, selection: c.selection, alias: alias, @@ -3312,11 +3312,11 @@ func (c *nullinetField) As(alias string) Field { } } -func (c *nullinetField) Alias() string { +func (c *nullblobField) Alias() string { return c.alias } -func (c *nullinetField) MaybeAlias() string { +func (c *nullblobField) MaybeAlias() string { if c.alias == "" { return c.name } else { @@ -3324,15 +3324,15 @@ func (c *nullinetField) MaybeAlias() string { } } -func (c *nullinetField) Name() string { +func (c *nullblobField) Name() string { return c.name } -func (c *nullinetField) Type() reflect.Type { - return typeNullInet +func (c *nullblobField) Type() reflect.Type { + return typeNullBlob } -func (c *nullinetField) Parent() Selectable { +func (c *nullblobField) Parent() Selectable { return c.selection } @@ -3340,51 +3340,51 @@ func (c *nullinetField) Parent() Selectable { -func (c *nullinetField) Eq(pred NullableInet) Condition { +func (c *nullblobField) Eq(pred NullableBlob) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: EqPredicate} } -func (c *nullinetField) IsEq(pred NullInetField) JoinCondition { +func (c *nullblobField) IsEq(pred NullBlobField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: EqPredicate} } -func (c *nullinetField) Gt(pred NullableInet) Condition { +func (c *nullblobField) Gt(pred NullableBlob) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GtPredicate} } -func (c *nullinetField) IsGt(pred NullInetField) JoinCondition { +func (c *nullblobField) IsGt(pred NullBlobField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GtPredicate} } -func (c *nullinetField) Ge(pred NullableInet) Condition { +func (c *nullblobField) Ge(pred NullableBlob) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: GePredicate} } -func (c *nullinetField) IsGe(pred NullInetField) JoinCondition { +func (c *nullblobField) IsGe(pred NullBlobField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: GePredicate} } -func (c *nullinetField) Lt(pred NullableInet) Condition { +func (c *nullblobField) Lt(pred NullableBlob) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LtPredicate} } -func (c *nullinetField) IsLt(pred NullInetField) JoinCondition { +func (c *nullblobField) IsLt(pred NullBlobField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LtPredicate} } -func (c *nullinetField) Le(pred NullableInet) Condition { +func (c *nullblobField) Le(pred NullableBlob) Condition { return Condition{Binding: FieldBinding{Value: pred, Field: c}, Predicate: LePredicate} } -func (c *nullinetField) IsLe(pred NullInetField) JoinCondition { +func (c *nullblobField) IsLe(pred NullBlobField) JoinCondition { return JoinCondition{Lhs: c, Rhs: pred, Predicate: LePredicate} } @@ -3392,54 +3392,54 @@ func (c *nullinetField) IsLe(pred NullInetField) JoinCondition { // -- -func NullInet(s Selectable, name string) NullInetField { - return &nullinetField{name: name, selection: s} +func NullBlob(s Selectable, name string) NullBlobField { + return &nullblobField{name: name, selection: s} } ////// -func (c *nullinetField) Avg() Field { +func (c *nullblobField) Avg() Field { return c.fct("Avg", "AVG(%s)") } -func (c *nullinetField) Max() Field { +func (c *nullblobField) Max() Field { return c.fct("Max", "MAX(%s)") } -func (c *nullinetField) Min() Field { +func (c *nullblobField) Min() Field { return c.fct("Min", "MIN(%s)") } -func (c *nullinetField) Ceil() Field { +func (c *nullblobField) Ceil() Field { return c.fct("Ceil", "CEIL(%s)") } -func (c *nullinetField) Div(_0 interface{}) Field { +func (c *nullblobField) Div(_0 interface{}) Field { return c.fct("Div", "%s / %v", _0) } -func (c *nullinetField) Cast(_0 interface{}) Field { +func (c *nullblobField) Cast(_0 interface{}) Field { return c.fct("Cast", "CAST(%s AS %s)", _0) } -func (c *nullinetField) Md5() Field { +func (c *nullblobField) Md5() Field { return c.fct("Md5", "MD5(%s)") } -func (c *nullinetField) Lower() Field { +func (c *nullblobField) Lower() Field { return c.fct("Lower", "LOWER(%s)") } -func (c *nullinetField) Hex() Field { +func (c *nullblobField) Hex() Field { return c.fct("Hex", "HEX(%s)") } -func (c *nullinetField) Substr2(_0 interface{}) Field { +func (c *nullblobField) Substr2(_0 interface{}) Field { return c.fct("Substr2", "SUBSTR(%s, %v)", _0) } -func (c *nullinetField) Substr3(_0,_1 interface{}) Field { +func (c *nullblobField) Substr3(_0,_1 interface{}) Field { return c.fct("Substr3", "SUBSTR(%s, %v, %v)", _0,_1) } diff --git a/sqlc/generator.go b/sqlc/generator.go index 7a5fe8f..d74e89c 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -20,11 +20,11 @@ var integer = regexp.MustCompile("INT") var int_64 = regexp.MustCompile("INTEGER|BIGINT") var float_32 = regexp.MustCompile("FLOAT") var float_64 = regexp.MustCompile("DOUBLE PRECISION|NUMERIC") -var varchar = regexp.MustCompile("VARCHAR|CHARACTER VARYING|TEXT") +var varchar = regexp.MustCompile("VARCHAR|CHARACTER VARYING|TEXT|CHAR") var datetime = regexp.MustCompile("TIMESTAMP|DATETIME") var date = regexp.MustCompile("DATE") var time_ = regexp.MustCompile("TIME") -var inet = regexp.MustCompile("INET") +var blob = regexp.MustCompile("INET|TINYBLOB|BLOB|MEDIUMBLOB|LONGBLOB") var dbType = regexp.MustCompile("mysql|postgres|sqlite") type Provenance struct { @@ -198,8 +198,8 @@ func infoSchema(d Dialect, schema string, db *sql.DB) ([]TableMeta, error) { fieldType = "Time" } else if boolean.MatchString(colType.String) { fieldType = "Bool" - } else if inet.MatchString(colType.String) { - fieldType = "Inet" + } else if blob.MatchString(colType.String) { + fieldType = "Blob" } if nullable { @@ -269,8 +269,8 @@ func sqlite(db *sql.DB) ([]TableMeta, error) { fieldType = "Time" } else if boolean.MatchString(colType.String) { fieldType = "Bool" - } else if inet.MatchString(colType.String) { - fieldType = "Inet" + } else if blob.MatchString(colType.String) { + fieldType = "Blob" } if nullable { diff --git a/sqlc/schema.go b/sqlc/schema.go index 213b82c..d2e215e 100644 --- a/sqlc/schema.go +++ b/sqlc/schema.go @@ -28,108 +28,108 @@ func bindata_read(data []byte, name string) ([]byte, error) { func sqlc_tmpl_fields_tmpl() ([]byte, error) { return bindata_read([]byte{ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x00, 0xff, 0xcc, 0x58, - 0x5f, 0x6f, 0xdb, 0x36, 0x10, 0x7f, 0xd7, 0xa7, 0x38, 0x18, 0x45, 0x21, - 0x07, 0xaa, 0x12, 0x6c, 0x45, 0x1f, 0x0c, 0xe4, 0xc1, 0x69, 0x9c, 0xd5, - 0x83, 0xeb, 0x04, 0xb1, 0xb2, 0x60, 0x18, 0x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f, 0x56, 0xab, 0x14, - 0xce, 0xc1, 0xe8, 0x85, 0x11, 0x8a, 0xae, 0x13, 0x3f, 0x61, 0x69, 0xc1, - 0x87, 0x46, 0xe5, 0x12, 0x31, 0x75, 0x55, 0xc8, 0x5b, 0x78, 0x97, 0x89, - 0x67, 0xff, 0x2c, 0x80, 0xb3, 0xa1, 0xad, 0x4c, 0x4b, 0x07, 0x1b, 0x5c, - 0xa5, 0x2b, 0x26, 0xbf, 0xff, 0xce, 0x81, 0x41, 0x2f, 0xf8, 0x67, 0x61, - 0x53, 0xf7, 0xc3, 0xfb, 0x1e, 0xdd, 0x0f, 0xef, 0x6d, 0xdd, 0x69, 0x26, - 0xbb, 0x7a, 0x22, 0x93, 0xfe, 0x99, 0xa5, 0xc2, 0x1d, 0x3a, 0xbf, 0xfc, - 0xfa, 0xf0, 0x22, 0xf9, 0xb6, 0xb4, 0x1c, 0xb9, 0x42, 0x8a, 0x4c, 0x05, - 0xac, 0x9d, 0xcd, 0x37, 0x69, 0xea, 0x26, 0x13, 0x6b, 0x11, 0x56, 0xab, - 0x3b, 0xb7, 0x24, 0x71, 0x33, 0x4b, 0x2b, 0xec, 0x21, 0x55, 0x54, 0x76, - 0xf5, 0xdd, 0xe4, 0xda, 0x36, 0xa4, 0xd1, 0xb4, 0xeb, 0xe5, 0xb8, 0x82, - 0x66, 0x88, 0x75, 0x58, 0xb9, 0x52, 0xdf, 0x6b, 0xe5, 0x26, 0xb5, 0xc2, - 0x47, 0xab, 0x6d, 0x7d, 0x87, 0x7a, 0x15, 0x41, 0x71, 0xdf, 0xd1, 0xdf, - 0x87, 0xc9, 0x61, 0xb1, 0x90, 0xb9, 0xc8, 0x1e, 0xfb, 0x4d, 0xf4, 0x7a, - 0xd3, 0x26, 0xda, 0xcb, 0x72, 0xd4, 0x60, 0xb8, 0xcf, 0xff, 0x60, 0x50, - 0x69, 0xb8, 0xbd, 0x75, 0x06, 0x02, 0x47, 0x93, 0xb4, 0x61, 0x9a, 0x15,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x82, 0xad, 0xbb, + 0xf9, 0x11, 0xac, 0x1f, 0x70, 0x81, 0xb7, 0xfb, 0x18, 0x6f, 0x0b, 0x03, + 0xcb, 0x72, 0x10, 0x80, 0x16, 0xe0, 0x76, 0x87, 0x02, 0xf1, 0xc6, 0xb2, + 0xdf, 0x11, 0xb8, 0xe1, 0xac, 0xf3, 0x85, 0xa6, 0x1f, 0xff, 0x0e, 0x00, + 0x00, 0xff, 0xff, 0x14, 0x91, 0xb5, 0x2c, 0x54, 0x14, 0x00, 0x00, }, "sqlc/tmpl/fields.tmpl", ) diff --git a/sqlc/sqlc.go b/sqlc/sqlc.go index 1226cfd..6c0fd2e 100644 --- a/sqlc/sqlc.go +++ b/sqlc/sqlc.go @@ -217,19 +217,19 @@ func Qualified(parts ...string) string { return strings.Join(tmp, ".") } -type NullableInet struct { +type NullableBlob struct { Inet []byte Valid bool // Valid is true if Inet is not NULL } // Scan implements the Scanner interface. -func (self *NullableInet) Scan(value interface{}) error { +func (self *NullableBlob) Scan(value interface{}) error { self.Inet, self.Valid = value.([]byte) return nil } // Value implements the driver Valuer interface. -func (self NullableInet) Value() (driver.Value, error) { +func (self NullableBlob) Value() (driver.Value, error) { if !self.Valid { return nil, nil } diff --git a/sqlc/tmpl/fields.tmpl b/sqlc/tmpl/fields.tmpl index 74e9ff0..5b83f23 100644 --- a/sqlc/tmpl/fields.tmpl +++ b/sqlc/tmpl/fields.tmpl @@ -18,14 +18,14 @@ var ( typeFloat32 = reflect.TypeOf(float32(0.)) typeFloat64 = reflect.TypeOf(float64(0.)) typeInt = reflect.TypeOf(int(0)) - typeInet = reflect.TypeOf([]byte{}) + typeBlob = reflect.TypeOf([]byte{}) typeInt64 = reflect.TypeOf(int64(0)) typeNullBool = reflect.TypeOf(sql.NullBool{}) typeNullDate = reflect.TypeOf(NullableDate{}) typeNullDatetime = reflect.TypeOf(NullableDatetime{}) typeNullFloat32 = reflect.TypeOf(sql.NullFloat64{}) typeNullFloat64 = reflect.TypeOf(sql.NullFloat64{}) - typeNullInet = reflect.TypeOf(NullableInet{}) + typeNullBlob = reflect.TypeOf(NullableBlob{}) typeNullInt = reflect.TypeOf(sql.NullInt64{}) typeNullInt64 = reflect.TypeOf(sql.NullInt64{}) typeNullString = reflect.TypeOf(sql.NullString{}) From 23c364ce39db63955de96302ab989fd96ff7d630 Mon Sep 17 00:00:00 2001 From: Jeremy Shute Date: Sun, 15 Mar 2015 13:41:52 -0400 Subject: [PATCH 17/17] add text variants --- sqlc/generator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlc/generator.go b/sqlc/generator.go index d74e89c..d7a6dd2 100644 --- a/sqlc/generator.go +++ b/sqlc/generator.go @@ -20,7 +20,7 @@ var integer = regexp.MustCompile("INT") var int_64 = regexp.MustCompile("INTEGER|BIGINT") var float_32 = regexp.MustCompile("FLOAT") var float_64 = regexp.MustCompile("DOUBLE PRECISION|NUMERIC") -var varchar = regexp.MustCompile("VARCHAR|CHARACTER VARYING|TEXT|CHAR") +var varchar = regexp.MustCompile("VARCHAR|CHARACTER VARYING|TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|CHAR") var datetime = regexp.MustCompile("TIMESTAMP|DATETIME") var date = regexp.MustCompile("DATE") var time_ = regexp.MustCompile("TIME")