adonis-lucid-soft-deletes icon indicating copy to clipboard operation
adonis-lucid-soft-deletes copied to clipboard

ambiguous error while join two table with soft delete

Open farshadfahimi opened this issue 2 years ago • 3 comments

I have two table with deleted_at fields and need to join both of them , but in the query builder when execute the query got ambiguous error on deleted_at colomn

farshadfahimi avatar Aug 21 '21 17:08 farshadfahimi

@farshadfahimi could you show me an example of your usecase?

radmen avatar Aug 21 '21 17:08 radmen

@radmen I have a model named Product and ProductCategories and both of them has deleted_at for soft deleting and I'm Generate a query like below bot on executaion got ambiguous error

Products.query().whereIn('products.id', array).join('products_categories', 'products.categories_id', 'products_categories.id')

the soft delete add the deleted_at where and got ambiguous error

I think when you generate the query it' better to add table_name in where queries and the problem would be solved

farshadfahimi avatar Aug 22 '21 19:08 farshadfahimi

@farshadfahimi thanks for the example. I'll see what can be done, though please mind that I'm not actively maintaining this package. If you'd like to help with a PR, you're more than welcome :)

radmen avatar Aug 23 '21 06:08 radmen