We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Given the SQL statement
SELECT * FROM ingredients WHERE EXISTS ( SELECT "1" AS one FROM dishes WHERE dishes.taste = 'umami' AND dishes.ingredient_id = ingredients.id );
scuttle suggests
Ingredient.select(Arel.star).where( Dish.select(:1.as('one')).where( Dish.arel_table[:taste].eq('umami').and( Dish.arel_table[:ingredient_id].eq(Ingredient.arel_table[:id]) ) ).exists )
which is incorrect, as .exists is defined only on a SelectManager, so we need #project:
.exists
SelectManager
#project
Ingredient.select(Arel.star).where( Dish.arel_table.project(:1.as('one')).where( # <---- Dish.arel_table[:taste].eq('umami').and( Dish.arel_table[:ingredient_id].eq(Ingredient.arel_table[:id]) ) ).exists )
Also, for the negation
SELECT * FROM ingredients WHERE NOT ( EXISTS ( SELECT "1" AS one FROM dishes WHERE dishes.taste = 'umami' AND dishes.ingredient_id = ingredients.id ));
scuttle seems to ignore the the negation:
We would need:
Ingredient.select(Arel.star).where.not( # <---- Dish.arel_table.project(:1.as('one')).where( # <---- Dish.arel_table[:taste].eq('umami').and( Dish.arel_table[:ingredient_id].eq(Ingredient.arel_table[:id]) ) ).exists )
The text was updated successfully, but these errors were encountered:
Thanks for the bug report @leoarnold. Do you know if project is always allowed in place of select?
project
select
Also, would this be something you'd be willing to dive in and fix?
Sorry, something went wrong.
No branches or pull requests
Given the SQL statement
scuttle suggests
which is incorrect, as
.exists
is defined only on aSelectManager
, so we need#project
:Also, for the negation
scuttle seems to ignore the the negation:
We would need:
The text was updated successfully, but these errors were encountered: