Closed
Description
Describe the bug
See expected behavior
Environment (please complete the following information):
- OS: linux/macosx
- Database: postgres
- Database driver: pg
- Jet version: 2.6.1
Code snippet
type User struct {
ID uuid.UUID `json:"id" sql:"primary_key" alias:"users.id"`
FirstName string `json:"first_name" alias:"users.first_name"`
LastName string `json:"last_name" alias:"users.last_name"`
Sex string `json:"sex" alias:"users.sex"`
IsDirectDescendant bool `json:"is_direct_descendant" alias:"users.is_direct_descendant"`
BirthDate *time.Time `json:"birth_date" alias:"users.birth_date"`
DeathDate *time.Time `json:"death_date" alias:"users.death_date"`
CreatedAt time.Time `json:"created_at" alias:"users.created_at"`
UpdatedAt *time.Time `json:"updated_at" alias:"users.updated_at"`
}
SELECT(
UserAddresses.AllColumns
SELECT_JSON_AGG(Users.AllColumns).
FROM(
Users.
INNER_JOIN(InternalUserAddresses, Users.ID.EQ(InternalUserAddresses.UserID)),
).
WHERE(InternalUserAddresses.ID.EQ(UserAddresses.ID)).
AS("users"),
).
FROM(UserAddresses)
Expected behavior
This query doesn't manage to map the users of an address because every field in the sub-query is aliased in camelCase but in my models it has tags were the json tags are in snake-case.
The only workaround is to alias all column manually.
It works great (as a SQL perspective) if I use a simple SELECT
but doesn't if I use SELECT_JSON_AGG