SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
6.56k stars 459 forks source link

Cannot use column in a like expression #2259

Open barsdeveloper opened 2 weeks ago

barsdeveloper commented 2 weeks ago

Description

A column expression is not accepted in LIKE condition

Steps to Reproduce

I have a table containing strings that are patterns (they contain wildcards like % and _). I need to get only the rows where this pattern column match a string literal This is a query example that is working in sqlite:

SELECT * FROM request_limit where 'https://api.ibkr.com/v1/api/iserver/account/order/status/123' like target;

I am trying to reproduce this query with the following code:

entities::request_limit::Entity::find()
    .select_only()
    .column(entities::request_limit::Column::Requests)
    .column(entities::request_limit::Column::TimeUnitMs)
    .column(entities::request_limit::Column::ConcurrentRequests)
    .filter(Expr::value(target).like(Expr::col(entities::request::Column::Target)));

Expected Behavior

Compiles successfully

Actual Behavior

I get an error:

required for `sea_orm::sea_query::Expr` to implement `IntoLikeExpr`