objection.js icon indicating copy to clipboard operation
objection.js copied to clipboard

relationMapping composite keys with same property names gives ambiguous column error

Open nikkwong opened this issue 3 years ago • 1 comments

Hi, I am trying to create a relationMapping between two composite keys which both share the same property names:

join: {
    from: [`table1.user_id`, `table1.hub_id`],
    to: [`table2.user_id`, `table2.hub_id`],
},

I'm getting a where "user_id" = $1 - column reference "user_id" is ambiguous error. Is there a way to create an alias for these keys? thank you.

nikkwong avatar Jan 26 '22 23:01 nikkwong

Could you add a .debug() to your query builder and share the logged query in full?

devinivy avatar Jan 27 '22 00:01 devinivy