You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We encountered an issue when using the cursor_by method in SeaORM with a JOIN operation in SQLite. Specifically, when performing a JOIN between two tables (e.g., table A and table B) and using cursor_by on a column from table B, the query fails. The generated SQL incorrectly references the column from table B as if it belongs to table A.
Environment
Database: SQLite
ORM: SeaORM
Version: The issue occurs in version 1.1.0, but not in 0.12.15.
Example
Here's a code snippet illustrating the issue:
let result = media_files::Entity::find().join(JoinType::LeftJoin,
media_file_albums::Relation::MediaFiles.def().rev(),).column(media_file_albums::Column::TrackNumber).cursor_by(media_file_albums::Column::TrackNumber).desc().first(20).all(&main_db).await.unwrap();
In this example, track_number is a column from media_file_albums, and we explicitly passed media_file_albums::Column::TrackNumber to cursor_by. However, the generated SQL incorrectly orders by "media_files"."track_number".
Thank you for your attention to this matter!
The text was updated successfully, but these errors were encountered:
I think to use a column from another table, it might be better to consider using function select_also and cursor_by_other.
Example
let result = media_files::Entity::find().select_also(media_file_albums::Entity).join(JoinType::LeftJoin,
media_file_albums::Relation::MediaFiles.def().rev(),).column(media_file_albums::Column::TrackNumber).cursor_by_other(media_file_albums::Column::TrackNumber).desc().first(20).all(&main_db).await.unwrap();
Description
We encountered an issue when using the
cursor_by
method in SeaORM with aJOIN
operation in SQLite. Specifically, when performing aJOIN
between two tables (e.g., table A and table B) and usingcursor_by
on a column from table B, the query fails. The generated SQL incorrectly references the column from table B as if it belongs to table A.Environment
Example
Here's a code snippet illustrating the issue:
Incorrect SQL Output
In this example,
track_number
is a column frommedia_file_albums
, and we explicitly passedmedia_file_albums::Column::TrackNumber
tocursor_by
. However, the generated SQL incorrectly orders by"media_files"."track_number"
.Thank you for your attention to this matter!
The text was updated successfully, but these errors were encountered: