Add test for - Special characters are not working in postgres password(for generator)
https://github.com/go-jet/jet/issues/95
This commit is contained in:
parent
8adfe45e38
commit
3015b79926
2 changed files with 44 additions and 1 deletions
|
|
@ -155,7 +155,7 @@ func TestInsert_ON_CONFLICT(t *testing.T) {
|
|||
ON_CONFLICT(table1ColBool).WHERE(table1ColBool.IS_NOT_FALSE()).DO_UPDATE(
|
||||
SET(table1ColBool.SET(Bool(true)),
|
||||
table2ColInt.SET(Int(1)),
|
||||
ColumnList{table1Col1, table1ColBool}.SET(jet.ROW(Int(2), String("two"))),
|
||||
ColumnList{table1Col1, table1ColBool}.SET(ROW(Int(2), String("two"))),
|
||||
).WHERE(table1Col1.GT(Int(2))),
|
||||
).
|
||||
RETURNING(table1Col1, table1ColBool)
|
||||
|
|
|
|||
|
|
@ -809,6 +809,49 @@ func TestScanNumericToNumber(t *testing.T) {
|
|||
require.Equal(t, number.Float64, float64(1.234567890111e+09))
|
||||
}
|
||||
|
||||
// QueryContext panic when the scanned value is nil and the destination is a slice of primitive
|
||||
// https://github.com/go-jet/jet/issues/91
|
||||
func TestScanToPrimitiveElementsSlice(t *testing.T) {
|
||||
tx, err := db.Begin()
|
||||
require.NoError(t, err)
|
||||
defer tx.Rollback()
|
||||
|
||||
// add actor without associated film (so that destination Title array is NULL).
|
||||
_, err = Actor.INSERT().
|
||||
MODEL(
|
||||
model.Actor{
|
||||
ActorID: 201,
|
||||
FirstName: "Brigitte",
|
||||
LastName: "Bardot",
|
||||
LastUpdate: time.Time{},
|
||||
},
|
||||
).Exec(tx)
|
||||
require.NoError(t, err)
|
||||
|
||||
stmt := SELECT(
|
||||
Actor.ActorID.AS("actor_id"),
|
||||
Film.Title.AS("title"),
|
||||
).FROM(
|
||||
Actor.
|
||||
LEFT_JOIN(FilmActor, Actor.ActorID.EQ(FilmActor.ActorID)).
|
||||
LEFT_JOIN(Film, Film.FilmID.EQ(FilmActor.FilmID)),
|
||||
).WHERE(
|
||||
Actor.ActorID.GT(Int(199)),
|
||||
).ORDER_BY(Actor.ActorID.DESC())
|
||||
|
||||
var dest []struct {
|
||||
ActorID int `sql:"primary_key"`
|
||||
Title []string
|
||||
}
|
||||
|
||||
err = stmt.Query(tx, &dest)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, dest[0].ActorID, 201)
|
||||
require.Equal(t, dest[0].Title, []string(nil))
|
||||
require.Equal(t, dest[1].ActorID, 200)
|
||||
require.Len(t, dest[1].Title, 20)
|
||||
}
|
||||
|
||||
var address256 = model.Address{
|
||||
AddressID: 256,
|
||||
Address: "1497 Yuzhou Drive",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue