`read all` fails on joined table with `where`d unique field
samolds opened this issue · 0 comments
samolds commented
okay so i've got the relationship in my db where a residence
is 1:1 with address
. but then a user
is 1:many with residence
something like:
-- residence -- address
|
user --- residence -- address
|
-- residence -- address
so i believe this should be a valid query:
read all (
select user residence address
join user.pk = residence.user_pk
join residence.address_pk = address.pk
where user.id = ?
where address.latitude > ?
where address.latitude < ?
where address.longitude > ?
where address.longitude < ?
)
I want to get all of the user/residence/rows dependent on a user id and a geoquery. a user could technically have multiple addresses within the same area. but i think because i added a where user.id = ?
, dbx thinks there would only be 1 row because user.id
is declared unique. the error is cannot limit/offset unique select
error.
NOTE: as already pointed out, the same user object could be loaded multiple times. breaking this up into two queries, like:
read all (
select residence address
join user.pk = residence.user_pk
...
)
would be more optimized.