You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this should be flagged as a bug or as a feature request.
At the moment, it is not possible to use custom types (i.e. non simple types) as primary key when joining (for example sql.NullInt64 or similar). The data will be extracted but the grouping will not be correct.
Code snippet
The following is the example in the Wiki but with the primary keys as sql.NullInt64 instead of int32
// Address struct has the same name and fields as auto-generated model structtypeAddressstruct {
ID sql.NullInt64`sql:"primary_key"`AddressLinestring
}
typeMyCustomerstruct {
ID sql.NullInt64`sql:"primary_key"`LastName*stringAddressAddress
}
typeMyCitystruct {
ID sql.NullInt64`sql:"primary_key"`NamestringCustomers []MyCustomer
}
dest2:= []MyCity{}
stmt2:=SELECT(
City.CityID.AS("my_city.id"), // snake caseCity.City.AS("myCity.Name"), // camel caseAddress.AddressID, // No need for aliasing. Address.Address, // Default aliasing still works. Customer.CustomerID.AS("My_Customer.id"), //mixed caseCustomer.LastName.AS("my customer.last name"), //with spaces
).FROM(
City.
INNER_JOIN(Address, Address.CityID.EQ(City.CityID)).
INNER_JOIN(Customer, Customer.AddressID.EQ(Address.AddressID)),
).WHERE(
City.City.EQ(String("London")).OR(City.City.EQ(String("York"))),
).ORDER_BY(
City.CityID, Address.AddressID, Customer.CustomerID,
)
err:=stmt2.Query(db, &dest2)
Instead of extracting 2 cities with 2 and 1 customers each respectively, it will extract 3 cities with 1 customer each. The first city will be repeated twice (reflecting how the join works). In code:
Not sure if this should be flagged as a bug or as a feature request.
At the moment, it is not possible to use custom types (i.e. non simple types) as primary key when joining (for example
sql.NullInt64
or similar). The data will be extracted but the grouping will not be correct.Code snippet
The following is the example in the Wiki but with the primary keys as
sql.NullInt64
instead ofint32
Instead of extracting 2 cities with 2 and 1 customers each respectively, it will extract 3 cities with 1 customer each. The first city will be repeated twice (reflecting how the join works). In code:
The proposed #197 fixes this.
The text was updated successfully, but these errors were encountered: