Identically named columns in multiple tables - How to use innerJoin.selectAll()?
Hey, I am new to using kysely, and also relatively new to using PostgreSQL.
I have trouble with the following query:
Because both
tables
and tableLeadStates
have identically named name
and id
as well as color
columns, this causes overlapping keys in my response. Intellisense does not seem to suggest that kysely is prefixing the tables. What am I doing wrong here and how do I solve this? I know that this is basically just how SQL works, but I am still wondering, how do I alias my selectAll() or add a prefix another way?Solution:Jump to solution
Hey 👋🏻
You have 3 options:
1. use table scoped
selectAll
on 1 table (selectAll('tables')
) and then select
the other table/s columns while aliasing columns that exist multiple "tables"....1 Reply
Solution
Hey 👋🏻
You have 3 options:
1. use table scoped
selectAll
on 1 table (selectAll('tables')
) and then select
the other table/s columns while aliasing columns that exist multiple "tables".
2. using select
entirely and aliasing columns that exist in multiple tables.
3. nesting. e.g. via jsonArrayFrom
. (https://kysely.dev/docs/recipes/relations)