Add Support For PostgreSQL "ANY" In ColumnTrait #1804
Closed
anshap1719
started this conversation in
Ideas
Replies: 3 comments 5 replies
-
Hi @billy1624, Any opinions? |
Beta Was this translation helpful? Give feedback.
0 replies
-
The example you provided is same as |
Beta Was this translation helpful? Give feedback.
4 replies
-
There is some syntax support for the ANY operator https://docs.rs/sea-query/latest/sea_query/extension/postgres/struct.PgFunc.html#method.any |
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
-
Motivation
Schema
Since this is a simple enough query, there really shouldn't be a need for using
Expr::cust
for this, which is what I presently have to use to achieve the following query:SELECT * FROM recipe WHERE 'Cheese' = ANY("ingredients");
Adding support for an
eq_any
method in the trait behind the postgres feature flag should be easy. I'd be happy to create a PR if this is something that you are interested in supporting.Proposed Solutions
Add new method to
ColumnTrait
with following signature:fn eq_any<V>(&self, value: V) -> SimpleExpr where V: Into<Value>
This will allow the query to look like this:
Entity::find().filter(Column::Ingredients.eq_any("Cheese"))
Current Workarounds
Currently, the same query has to be implemented like this:
Entity::find().filter(Expr::cust("'Cheese' = ANY(\"ingredients\")"))
Beta Was this translation helpful? Give feedback.
All reactions