Skip to content

Commit

Permalink
Update test.
Browse files Browse the repository at this point in the history
  • Loading branch information
go-jet committed Apr 14, 2023
1 parent 14bd3b6 commit 73d7e48
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions tests/postgres/select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ LIMIT 15;
}

// https://github.com/go-jet/jet/issues/226
func TestGroupingBug226(t *testing.T) {
func TestDuplicateSlicesInDestination(t *testing.T) {

type Staffs struct {
StaffList []model.Staff
Expand All @@ -397,8 +397,9 @@ func TestGroupingBug226(t *testing.T) {
type MyStore struct {
model.Store

StaffList []model.Staff
Staffs Staffs
StaffList []model.Staff
StaffList2 []model.Staff
Staffs Staffs
}

stmt := SELECT(
Expand Down Expand Up @@ -438,6 +439,21 @@ func TestGroupingBug226(t *testing.T) {
"Picture": "iVBORw0KWgo="
}
],
"StaffList2": [
{
"StaffID": 1,
"FirstName": "Mike",
"LastName": "Hillyer",
"AddressID": 3,
"Email": "[email protected]",
"StoreID": 1,
"Active": true,
"Username": "Mike",
"Password": "8cb2237d0679ca88db6464eac60da96345513964",
"LastUpdate": "2006-05-16T16:13:11.79328Z",
"Picture": "iVBORw0KWgo="
}
],
"Staffs": {
"StaffList": [
{
Expand Down Expand Up @@ -476,6 +492,21 @@ func TestGroupingBug226(t *testing.T) {
"Picture": null
}
],
"StaffList2": [
{
"StaffID": 2,
"FirstName": "Jon",
"LastName": "Stephens",
"AddressID": 4,
"Email": "[email protected]",
"StoreID": 2,
"Active": true,
"Username": "Jon",
"Password": "8cb2237d0679ca88db6464eac60da96345513964",
"LastUpdate": "2006-05-16T16:13:11.79328Z",
"Picture": null
}
],
"Staffs": {
"StaffList": [
{
Expand Down Expand Up @@ -543,15 +574,13 @@ ORDER BY city.city_id, address.address_id, customer.customer_id;
Customers []struct {
model.Customer

Address []model.Address
Address model.Address
}
}

err := stmt.Query(db, &dest)
require.NoError(t, err)

testutils.PrintJson(dest)

require.Equal(t, len(dest), 2)
require.Equal(t, dest[0].City.City, "London")
require.Equal(t, dest[1].City.City, "York")
Expand All @@ -572,7 +601,7 @@ func TestExecution2(t *testing.T) {
ID int32 `sql:"primary_key"`
LastName *string

Address []MyAddress
Address MyAddress
}

type MyCity struct {
Expand Down Expand Up @@ -622,7 +651,6 @@ ORDER BY city.city_id, address.address_id, customer.customer_id;
require.Equal(t, len(dest[0].Customers), 2)
require.Equal(t, *dest[0].Customers[0].LastName, "Hoffman")
require.Equal(t, *dest[0].Customers[1].LastName, "Vines")

}

func TestExecution3(t *testing.T) {
Expand Down

0 comments on commit 73d7e48

Please sign in to comment.