Replies: 1 comment 1 reply
-
That's seems to be pretty interesting, however sorry I don't have a full grasp of the proposal. Would you mind opening a PR with some testcases? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My simplified use case
Let's define a
country
table, acity
table that references it, and atrip
table that references two cities: the source and the destination. Then, for a giventrip.id
, I want to selectsource_country_name
anddestination_country_name
in a single ergonomic query. This can be achieved by using two parallel join chains, with table aliases added for disambiguation.For quite a while, I was stuck trying to compile this:
My current workaround
Eventually, I figured out that I can define
and fill the hole with that:
Proposed solutions
Please add and document some hepler method that can be quicky discovered via IDE autocompletion or docs and express my intent concisely:
Once we've set on the desired API, maybe I can even implement it, this seems to be easy. If we see that the implementation will take a while or won't happen at all, let's at least mention my workaround in the docs.
On a side note, I'd really appreciate if I could achieve the same thing with
find_also_related()
/find_also_linked()
instead ofjoin()
/join_as()
. That's really the idiomaticsea-orm
way of doing joins, IMO. And it's less verbose, especiallyfind_also_linked()
. But seems like we need basic #1028 first, before talking about using aliases there.Approximate migration code for playing around
Beta Was this translation helpful? Give feedback.
All reactions