Generator clean up.
Ensure all sql types can be processed.
This commit is contained in:
parent
b3a52ceb31
commit
64ba909381
21 changed files with 495 additions and 208 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package tests
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/sub0zero/go-sqlbuilder/sqlbuilder"
|
||||
"github.com/sub0zero/go-sqlbuilder/tests/.test_files/dvd_rental/dvds/model"
|
||||
"gotest.tools/assert"
|
||||
|
|
@ -20,6 +21,10 @@ func assertQuery(t *testing.T, query sqlbuilder.Statement, expectedQuery string,
|
|||
assert.Equal(t, debuqSql, expectedQuery)
|
||||
}
|
||||
|
||||
func boolPtr(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
func int16Ptr(i int16) *int16 {
|
||||
return &i
|
||||
}
|
||||
|
|
@ -28,11 +33,48 @@ func int32Ptr(i int32) *int32 {
|
|||
return &i
|
||||
}
|
||||
|
||||
func int64Ptr(i int64) *int64 {
|
||||
return &i
|
||||
}
|
||||
|
||||
func stringPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func timeWithoutTimeZone(t string, precision int) *time.Time {
|
||||
func float32Ptr(f float32) *float32 {
|
||||
return &f
|
||||
}
|
||||
func float64Ptr(f float64) *float64 {
|
||||
return &f
|
||||
}
|
||||
|
||||
func uuidPtr(u string) *uuid.UUID {
|
||||
uuid := uuid.MustParse(u)
|
||||
|
||||
return &uuid
|
||||
}
|
||||
|
||||
func timeWithoutTimeZone(t string) *time.Time {
|
||||
time, err := time.Parse("15:04:05", t)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &time
|
||||
}
|
||||
|
||||
func timeWithTimeZone(t string) *time.Time {
|
||||
time, err := time.Parse("15:04:05 -0700", t)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &time
|
||||
}
|
||||
|
||||
func timestampWithoutTimeZone(t string, precision int) *time.Time {
|
||||
|
||||
precisionStr := ""
|
||||
|
||||
|
|
@ -49,6 +91,27 @@ func timeWithoutTimeZone(t string, precision int) *time.Time {
|
|||
return &time
|
||||
}
|
||||
|
||||
func timestampWithTimeZone(t string, precision int) *time.Time {
|
||||
|
||||
precisionStr := ""
|
||||
|
||||
if precision > 0 {
|
||||
precisionStr = "." + strings.Repeat("9", precision)
|
||||
}
|
||||
|
||||
time, err := time.Parse("2006-01-02 15:04:05"+precisionStr+" -0700 MST", t)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &time
|
||||
}
|
||||
|
||||
func M3(a, b, c interface{}) []interface{} {
|
||||
return []interface{}{a, b, c}
|
||||
}
|
||||
|
||||
var customer0 = model.Customer{
|
||||
CustomerID: 1,
|
||||
StoreID: 1,
|
||||
|
|
@ -57,8 +120,8 @@ var customer0 = model.Customer{
|
|||
Email: stringPtr("mary.smith@sakilacustomer.org"),
|
||||
AddressID: 5,
|
||||
Activebool: true,
|
||||
CreateDate: *timeWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: timeWithoutTimeZone("2013-05-26 14:49:45.738", 3),
|
||||
CreateDate: *timestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: timestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
|
||||
Active: int32Ptr(1),
|
||||
}
|
||||
|
||||
|
|
@ -70,8 +133,8 @@ var customer1 = model.Customer{
|
|||
Email: stringPtr("patricia.johnson@sakilacustomer.org"),
|
||||
AddressID: 6,
|
||||
Activebool: true,
|
||||
CreateDate: *timeWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: timeWithoutTimeZone("2013-05-26 14:49:45.738", 3),
|
||||
CreateDate: *timestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: timestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
|
||||
Active: int32Ptr(1),
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +146,7 @@ var lastCustomer = model.Customer{
|
|||
Email: stringPtr("austin.cintron@sakilacustomer.org"),
|
||||
AddressID: 605,
|
||||
Activebool: true,
|
||||
CreateDate: *timeWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: timeWithoutTimeZone("2013-05-26 14:49:45.738", 3),
|
||||
CreateDate: *timestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: timestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
|
||||
Active: int32Ptr(1),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue