Add reserved words for MySQL.
This commit is contained in:
parent
241ea0d6d6
commit
926b88ed40
12 changed files with 573 additions and 178 deletions
|
|
@ -1066,32 +1066,32 @@ LIMIT $6;
|
|||
}
|
||||
|
||||
var allTypesRow0 = model.AllTypes{
|
||||
SmallIntPtr: Int16Ptr(14),
|
||||
SmallIntPtr: testutils.Int16Ptr(14),
|
||||
SmallInt: 14,
|
||||
IntegerPtr: Int32Ptr(300),
|
||||
IntegerPtr: testutils.Int32Ptr(300),
|
||||
Integer: 300,
|
||||
BigIntPtr: Int64Ptr(50000),
|
||||
BigIntPtr: testutils.Int64Ptr(50000),
|
||||
BigInt: 5000,
|
||||
DecimalPtr: Float64Ptr(1.11),
|
||||
DecimalPtr: testutils.Float64Ptr(1.11),
|
||||
Decimal: 1.11,
|
||||
NumericPtr: Float64Ptr(2.22),
|
||||
NumericPtr: testutils.Float64Ptr(2.22),
|
||||
Numeric: 2.22,
|
||||
RealPtr: Float32Ptr(5.55),
|
||||
RealPtr: testutils.Float32Ptr(5.55),
|
||||
Real: 5.55,
|
||||
DoublePrecisionPtr: Float64Ptr(11111111.22),
|
||||
DoublePrecisionPtr: testutils.Float64Ptr(11111111.22),
|
||||
DoublePrecision: 11111111.22,
|
||||
Smallserial: 1,
|
||||
Serial: 1,
|
||||
Bigserial: 1,
|
||||
//MoneyPtr: nil,
|
||||
//Money:
|
||||
VarCharPtr: StringPtr("ABBA"),
|
||||
VarCharPtr: testutils.StringPtr("ABBA"),
|
||||
VarChar: "ABBA",
|
||||
CharPtr: StringPtr("JOHN "),
|
||||
CharPtr: testutils.StringPtr("JOHN "),
|
||||
Char: "JOHN ",
|
||||
TextPtr: StringPtr("Some text"),
|
||||
TextPtr: testutils.StringPtr("Some text"),
|
||||
Text: "Some text",
|
||||
ByteaPtr: ByteArrayPtr([]byte("bytea")),
|
||||
ByteaPtr: testutils.ByteArrayPtr([]byte("bytea")),
|
||||
Bytea: []byte("bytea"),
|
||||
TimestampzPtr: testutils.TimestampWithTimeZone("1999-01-08 13:05:06 +0100 CET", 0),
|
||||
Timestampz: *testutils.TimestampWithTimeZone("1999-01-08 13:05:06 +0100 CET", 0),
|
||||
|
|
@ -1103,31 +1103,31 @@ var allTypesRow0 = model.AllTypes{
|
|||
Timez: *testutils.TimeWithTimeZone("04:05:06 -0800"),
|
||||
TimePtr: testutils.TimeWithoutTimeZone("04:05:06"),
|
||||
Time: *testutils.TimeWithoutTimeZone("04:05:06"),
|
||||
IntervalPtr: StringPtr("3 days 04:05:06"),
|
||||
IntervalPtr: testutils.StringPtr("3 days 04:05:06"),
|
||||
Interval: "3 days 04:05:06",
|
||||
BooleanPtr: BoolPtr(true),
|
||||
BooleanPtr: testutils.BoolPtr(true),
|
||||
Boolean: false,
|
||||
PointPtr: StringPtr("(2,3)"),
|
||||
BitPtr: StringPtr("101"),
|
||||
PointPtr: testutils.StringPtr("(2,3)"),
|
||||
BitPtr: testutils.StringPtr("101"),
|
||||
Bit: "101",
|
||||
BitVaryingPtr: StringPtr("101111"),
|
||||
BitVaryingPtr: testutils.StringPtr("101111"),
|
||||
BitVarying: "101111",
|
||||
TsvectorPtr: StringPtr("'supernova':1"),
|
||||
TsvectorPtr: testutils.StringPtr("'supernova':1"),
|
||||
Tsvector: "'supernova':1",
|
||||
UUIDPtr: UUIDPtr("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"),
|
||||
UUIDPtr: testutils.UUIDPtr("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"),
|
||||
UUID: uuid.MustParse("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"),
|
||||
XMLPtr: StringPtr("<Sub>abc</Sub>"),
|
||||
XMLPtr: testutils.StringPtr("<Sub>abc</Sub>"),
|
||||
XML: "<Sub>abc</Sub>",
|
||||
JSONPtr: StringPtr(`{"a": 1, "b": 3}`),
|
||||
JSONPtr: testutils.StringPtr(`{"a": 1, "b": 3}`),
|
||||
JSON: `{"a": 1, "b": 3}`,
|
||||
JsonbPtr: StringPtr(`{"a": 1, "b": 3}`),
|
||||
JsonbPtr: testutils.StringPtr(`{"a": 1, "b": 3}`),
|
||||
Jsonb: `{"a": 1, "b": 3}`,
|
||||
IntegerArrayPtr: StringPtr("{1,2,3}"),
|
||||
IntegerArrayPtr: testutils.StringPtr("{1,2,3}"),
|
||||
IntegerArray: "{1,2,3}",
|
||||
TextArrayPtr: StringPtr("{breakfast,consulting}"),
|
||||
TextArrayPtr: testutils.StringPtr("{breakfast,consulting}"),
|
||||
TextArray: "{breakfast,consulting}",
|
||||
JsonbArray: `{"{\"a\": 1, \"b\": 2}","{\"a\": 3, \"b\": 4}"}`,
|
||||
TextMultiDimArrayPtr: StringPtr("{{meeting,lunch},{training,presentation}}"),
|
||||
TextMultiDimArrayPtr: testutils.StringPtr("{{meeting,lunch},{training,presentation}}"),
|
||||
TextMultiDimArray: "{{meeting,lunch},{training,presentation}}",
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ WHERE all_types.uuid = 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11';
|
|||
err := query.Query(db, &result)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, result.UUID, uuid.MustParse("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"))
|
||||
testutils.AssertDeepEqual(t, result.UUIDPtr, UUIDPtr("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"))
|
||||
testutils.AssertDeepEqual(t, result.UUIDPtr, testutils.UUIDPtr("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"))
|
||||
}
|
||||
|
||||
func TestUUIDComplex(t *testing.T) {
|
||||
|
|
@ -280,7 +280,7 @@ ORDER BY employee.employee_id;
|
|||
FirstName: "Salley",
|
||||
LastName: "Lester",
|
||||
EmploymentDate: testutils.TimestampWithTimeZone("1999-01-08 04:05:06 +0100 CET", 1),
|
||||
ManagerID: Int32Ptr(3),
|
||||
ManagerID: testutils.Int32Ptr(3),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ FROM test_sample."WEIRD NAMES TABLE";
|
|||
WeirdColumnName5: "Doe",
|
||||
WeirdColumnName6: "Doe",
|
||||
WeirdColumnName7: "Doe",
|
||||
Weirdcolumnname8: StringPtr("Doe"),
|
||||
Weirdcolumnname8: testutils.StringPtr("Doe"),
|
||||
WeirdColName9: "Doe",
|
||||
WeirdColuName10: "Doe",
|
||||
WeirdColuName11: "Doe",
|
||||
|
|
|
|||
|
|
@ -505,10 +505,10 @@ func TestScanToSlice(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, len(dest), 2)
|
||||
testutils.AssertDeepEqual(t, dest[0].Film, film1)
|
||||
testutils.AssertDeepEqual(t, dest[0].IDs, []*int32{Int32Ptr(1), Int32Ptr(2), Int32Ptr(3), Int32Ptr(4),
|
||||
Int32Ptr(5), Int32Ptr(6), Int32Ptr(7), Int32Ptr(8)})
|
||||
testutils.AssertDeepEqual(t, dest[0].IDs, []*int32{testutils.Int32Ptr(1), testutils.Int32Ptr(2), testutils.Int32Ptr(3), testutils.Int32Ptr(4),
|
||||
testutils.Int32Ptr(5), testutils.Int32Ptr(6), testutils.Int32Ptr(7), testutils.Int32Ptr(8)})
|
||||
testutils.AssertDeepEqual(t, dest[1].Film, film2)
|
||||
testutils.AssertDeepEqual(t, dest[1].IDs, []*int32{Int32Ptr(9), Int32Ptr(10)})
|
||||
testutils.AssertDeepEqual(t, dest[1].IDs, []*int32{testutils.Int32Ptr(9), testutils.Int32Ptr(10)})
|
||||
})
|
||||
|
||||
t.Run("complex struct 1", func(t *testing.T) {
|
||||
|
|
@ -726,10 +726,10 @@ func TestStructScanAllNull(t *testing.T) {
|
|||
var address256 = model.Address{
|
||||
AddressID: 256,
|
||||
Address: "1497 Yuzhou Drive",
|
||||
Address2: StringPtr(""),
|
||||
Address2: testutils.StringPtr(""),
|
||||
District: "England",
|
||||
CityID: 312,
|
||||
PostalCode: StringPtr("3433"),
|
||||
PostalCode: testutils.StringPtr("3433"),
|
||||
Phone: "246810237916",
|
||||
LastUpdate: *testutils.TimestampWithoutTimeZone("2006-02-15 09:45:30", 0),
|
||||
}
|
||||
|
|
@ -737,10 +737,10 @@ var address256 = model.Address{
|
|||
var addres517 = model.Address{
|
||||
AddressID: 517,
|
||||
Address: "548 Uruapan Street",
|
||||
Address2: StringPtr(""),
|
||||
Address2: testutils.StringPtr(""),
|
||||
District: "Ontario",
|
||||
CityID: 312,
|
||||
PostalCode: StringPtr("35653"),
|
||||
PostalCode: testutils.StringPtr("35653"),
|
||||
Phone: "879347453467",
|
||||
LastUpdate: *testutils.TimestampWithoutTimeZone("2006-02-15 09:45:30", 0),
|
||||
}
|
||||
|
|
@ -750,12 +750,12 @@ var customer256 = model.Customer{
|
|||
StoreID: 2,
|
||||
FirstName: "Mattie",
|
||||
LastName: "Hoffman",
|
||||
Email: StringPtr("mattie.hoffman@sakilacustomer.org"),
|
||||
Email: testutils.StringPtr("mattie.hoffman@sakilacustomer.org"),
|
||||
AddressID: 256,
|
||||
Activebool: true,
|
||||
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 0),
|
||||
Active: Int32Ptr(1),
|
||||
Active: testutils.Int32Ptr(1),
|
||||
}
|
||||
|
||||
var customer512 = model.Customer{
|
||||
|
|
@ -763,12 +763,12 @@ var customer512 = model.Customer{
|
|||
StoreID: 1,
|
||||
FirstName: "Cecil",
|
||||
LastName: "Vines",
|
||||
Email: StringPtr("cecil.vines@sakilacustomer.org"),
|
||||
Email: testutils.StringPtr("cecil.vines@sakilacustomer.org"),
|
||||
AddressID: 517,
|
||||
Activebool: true,
|
||||
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 0),
|
||||
Active: Int32Ptr(1),
|
||||
Active: testutils.Int32Ptr(1),
|
||||
}
|
||||
|
||||
var countryUk = model.Country{
|
||||
|
|
@ -801,32 +801,32 @@ var inventory2 = model.Inventory{
|
|||
var film1 = model.Film{
|
||||
FilmID: 1,
|
||||
Title: "Academy Dinosaur",
|
||||
Description: StringPtr("A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies"),
|
||||
ReleaseYear: Int32Ptr(2006),
|
||||
Description: testutils.StringPtr("A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies"),
|
||||
ReleaseYear: testutils.Int32Ptr(2006),
|
||||
LanguageID: 1,
|
||||
RentalDuration: 6,
|
||||
RentalRate: 0.99,
|
||||
Length: Int16Ptr(86),
|
||||
Length: testutils.Int16Ptr(86),
|
||||
ReplacementCost: 20.99,
|
||||
Rating: &pgRating,
|
||||
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
|
||||
SpecialFeatures: StringPtr("{\"Deleted Scenes\",\"Behind the Scenes\"}"),
|
||||
SpecialFeatures: testutils.StringPtr("{\"Deleted Scenes\",\"Behind the Scenes\"}"),
|
||||
Fulltext: "'academi':1 'battl':15 'canadian':20 'dinosaur':2 'drama':5 'epic':4 'feminist':8 'mad':11 'must':14 'rocki':21 'scientist':12 'teacher':17",
|
||||
}
|
||||
|
||||
var film2 = model.Film{
|
||||
FilmID: 2,
|
||||
Title: "Ace Goldfinger",
|
||||
Description: StringPtr("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
|
||||
ReleaseYear: Int32Ptr(2006),
|
||||
Description: testutils.StringPtr("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
|
||||
ReleaseYear: testutils.Int32Ptr(2006),
|
||||
LanguageID: 1,
|
||||
RentalDuration: 3,
|
||||
RentalRate: 4.99,
|
||||
Length: Int16Ptr(48),
|
||||
Length: testutils.Int16Ptr(48),
|
||||
ReplacementCost: 12.99,
|
||||
Rating: &gRating,
|
||||
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
|
||||
SpecialFeatures: StringPtr(`{Trailers,"Deleted Scenes"}`),
|
||||
SpecialFeatures: testutils.StringPtr(`{Trailers,"Deleted Scenes"}`),
|
||||
Fulltext: `'ace':1 'administr':9 'ancient':19 'astound':4 'car':17 'china':20 'databas':8 'epistl':5 'explor':12 'find':15 'goldfing':2 'must':14`,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -982,16 +982,16 @@ ORDER BY film.film_id ASC;
|
|||
testutils.AssertDeepEqual(t, maxRentalRateFilms[0], model.Film{
|
||||
FilmID: 2,
|
||||
Title: "Ace Goldfinger",
|
||||
Description: StringPtr("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
|
||||
ReleaseYear: Int32Ptr(2006),
|
||||
Description: testutils.StringPtr("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
|
||||
ReleaseYear: testutils.Int32Ptr(2006),
|
||||
LanguageID: 1,
|
||||
RentalRate: 4.99,
|
||||
Length: Int16Ptr(48),
|
||||
Length: testutils.Int16Ptr(48),
|
||||
ReplacementCost: 12.99,
|
||||
Rating: &gRating,
|
||||
RentalDuration: 3,
|
||||
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
|
||||
SpecialFeatures: StringPtr("{Trailers,\"Deleted Scenes\"}"),
|
||||
SpecialFeatures: testutils.StringPtr("{Trailers,\"Deleted Scenes\"}"),
|
||||
Fulltext: "'ace':1 'administr':9 'ancient':19 'astound':4 'car':17 'china':20 'databas':8 'epistl':5 'explor':12 'find':15 'goldfing':2 'must':14",
|
||||
})
|
||||
}
|
||||
|
|
@ -1130,11 +1130,11 @@ ORDER BY customer_payment_sum."amount_sum" ASC;
|
|||
FirstName: "Brian",
|
||||
LastName: "Wyman",
|
||||
AddressID: 323,
|
||||
Email: StringPtr("brian.wyman@sakilacustomer.org"),
|
||||
Email: testutils.StringPtr("brian.wyman@sakilacustomer.org"),
|
||||
Activebool: true,
|
||||
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
|
||||
Active: Int32Ptr(1),
|
||||
Active: testutils.Int32Ptr(1),
|
||||
})
|
||||
|
||||
assert.Equal(t, customersWithAmounts[0].AmountSum, 27.93)
|
||||
|
|
@ -1846,8 +1846,8 @@ func TestDynamicCondition(t *testing.T) {
|
|||
Active *bool
|
||||
}
|
||||
|
||||
request.CustomerID = Int64Ptr(1)
|
||||
request.Active = BoolPtr(true)
|
||||
request.CustomerID = testutils.Int64Ptr(1)
|
||||
request.Active = testutils.BoolPtr(true)
|
||||
|
||||
// ...
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ WHERE link.id = 0;
|
|||
`
|
||||
testutils.AssertDebugStatementSql(t, stmt, expectedSQL, int64(0), int64(0))
|
||||
|
||||
assertExecErr(t, stmt, "pq: number of columns does not match number of values")
|
||||
testutils.AssertExecErr(t, stmt, db, "pq: number of columns does not match number of values")
|
||||
}
|
||||
|
||||
func TestUpdateWithModelData(t *testing.T) {
|
||||
|
|
@ -241,7 +241,7 @@ WHERE link.id = 201;
|
|||
`
|
||||
testutils.AssertDebugStatementSql(t, stmt, expectedSQL, "http://www.duckduckgo.com", "DuckDuckGo", nil, nil, int64(201))
|
||||
|
||||
assertExecErr(t, stmt, "pq: number of columns does not match number of values")
|
||||
testutils.AssertExecErr(t, stmt, db, "pq: number of columns does not match number of values")
|
||||
}
|
||||
|
||||
func TestUpdateQueryContext(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"github.com/go-jet/jet/internal/jet"
|
||||
"github.com/go-jet/jet/internal/testutils"
|
||||
"github.com/go-jet/jet/tests/.gentestdata/jetdb/dvds/model"
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
|
|
@ -19,60 +18,17 @@ func AssertExec(t *testing.T, stmt jet.Statement, rowsAffected int64) {
|
|||
assert.Equal(t, rows, rowsAffected)
|
||||
}
|
||||
|
||||
func assertExecErr(t *testing.T, stmt jet.Statement, errorStr string) {
|
||||
_, err := stmt.Exec(db)
|
||||
|
||||
assert.Error(t, err, errorStr)
|
||||
}
|
||||
|
||||
func BoolPtr(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
func Int16Ptr(i int16) *int16 {
|
||||
return &i
|
||||
}
|
||||
|
||||
func Int32Ptr(i int32) *int32 {
|
||||
return &i
|
||||
}
|
||||
|
||||
func Int64Ptr(i int64) *int64 {
|
||||
return &i
|
||||
}
|
||||
|
||||
func StringPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func ByteArrayPtr(arr []byte) *[]byte {
|
||||
return &arr
|
||||
}
|
||||
|
||||
func Float32Ptr(f float32) *float32 {
|
||||
return &f
|
||||
}
|
||||
func Float64Ptr(f float64) *float64 {
|
||||
return &f
|
||||
}
|
||||
|
||||
func UUIDPtr(u string) *uuid.UUID {
|
||||
newUUID := uuid.MustParse(u)
|
||||
|
||||
return &newUUID
|
||||
}
|
||||
|
||||
var customer0 = model.Customer{
|
||||
CustomerID: 1,
|
||||
StoreID: 1,
|
||||
FirstName: "Mary",
|
||||
LastName: "Smith",
|
||||
Email: StringPtr("mary.smith@sakilacustomer.org"),
|
||||
Email: testutils.StringPtr("mary.smith@sakilacustomer.org"),
|
||||
AddressID: 5,
|
||||
Activebool: true,
|
||||
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
|
||||
Active: Int32Ptr(1),
|
||||
Active: testutils.Int32Ptr(1),
|
||||
}
|
||||
|
||||
var customer1 = model.Customer{
|
||||
|
|
@ -80,12 +36,12 @@ var customer1 = model.Customer{
|
|||
StoreID: 1,
|
||||
FirstName: "Patricia",
|
||||
LastName: "Johnson",
|
||||
Email: StringPtr("patricia.johnson@sakilacustomer.org"),
|
||||
Email: testutils.StringPtr("patricia.johnson@sakilacustomer.org"),
|
||||
AddressID: 6,
|
||||
Activebool: true,
|
||||
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
|
||||
Active: Int32Ptr(1),
|
||||
Active: testutils.Int32Ptr(1),
|
||||
}
|
||||
|
||||
var lastCustomer = model.Customer{
|
||||
|
|
@ -93,10 +49,10 @@ var lastCustomer = model.Customer{
|
|||
StoreID: 2,
|
||||
FirstName: "Austin",
|
||||
LastName: "Cintron",
|
||||
Email: StringPtr("austin.cintron@sakilacustomer.org"),
|
||||
Email: testutils.StringPtr("austin.cintron@sakilacustomer.org"),
|
||||
AddressID: 605,
|
||||
Activebool: true,
|
||||
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
|
||||
Active: Int32Ptr(1),
|
||||
Active: testutils.Int32Ptr(1),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue