SeaQL / SeaQL/sea-orm

Cannot use column in a like expression

Open
#2,259 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:like-expr Category:enhancement
Dominant language
Rust
Stars
9.9k
Forks
735
Avg merge
6h 36m
Merged PRs (30d)
8

Description

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`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Expr::value(target).like(Expr::col(...)) entry point and investigate the IntoLikeExpr compilation error in the supplied Rust reproduction. Compare the expression types supported by the query builder and verify the expected result by confirming that a column can be used in the LIKE condition and the example compiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.