-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": "[email protected]", | ||
"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": "[email protected]", | ||
"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) { | ||
|