diff --git a/tests/postgres/select_test.go b/tests/postgres/select_test.go index c775e844..a6d95886 100644 --- a/tests/postgres/select_test.go +++ b/tests/postgres/select_test.go @@ -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 @@ -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( @@ -438,6 +439,21 @@ func TestGroupingBug226(t *testing.T) { "Picture": "iVBORw0KWgo=" } ], + "StaffList2": [ + { + "StaffID": 1, + "FirstName": "Mike", + "LastName": "Hillyer", + "AddressID": 3, + "Email": "Mike.Hillyer@sakilastaff.com", + "StoreID": 1, + "Active": true, + "Username": "Mike", + "Password": "8cb2237d0679ca88db6464eac60da96345513964", + "LastUpdate": "2006-05-16T16:13:11.79328Z", + "Picture": "iVBORw0KWgo=" + } + ], "Staffs": { "StaffList": [ { @@ -476,6 +492,21 @@ func TestGroupingBug226(t *testing.T) { "Picture": null } ], + "StaffList2": [ + { + "StaffID": 2, + "FirstName": "Jon", + "LastName": "Stephens", + "AddressID": 4, + "Email": "Jon.Stephens@sakilastaff.com", + "StoreID": 2, + "Active": true, + "Username": "Jon", + "Password": "8cb2237d0679ca88db6464eac60da96345513964", + "LastUpdate": "2006-05-16T16:13:11.79328Z", + "Picture": null + } + ], "Staffs": { "StaffList": [ { @@ -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") @@ -572,7 +601,7 @@ func TestExecution2(t *testing.T) { ID int32 `sql:"primary_key"` LastName *string - Address []MyAddress + Address MyAddress } type MyCity struct { @@ -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) {