SeaQL / SeaQL/sea-orm

Cursor on joined table

Open
#2,258 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:pagination Area:query-builder
Dominant language
Rust
Stars
9.9k
Forks
735
Avg merge
6h 36m
Merged PRs (30d)
8

Description

Description

SeaORM assumes that column passed in cursor_by is in the original table.

Steps to Reproduce

  1. Select from table
  2. Join with another table
  3. use cursor_by using column from second table
Expected Behavior

Use table that I've specified.

Actual Behavior

SeaOrm assumes that column that I want to cursor_by is inside main table.

Reproduces How Often

Always.

Workarounds

I am not aware of any.

Reproducible Example

gallery_media::Entity::find()
        .left_join(galleries::Entity)
        .cursor_by(galleries::Column::Score);

This throws following error

Query Error: error returned from database: 1054 (42S22): Unknown column 'gallery_categories.score' in 'order clause'

Versions

├── sea-orm v0.12.15
│ ├── sea-orm-macros v0.12.15 (proc-macro)
│ │ ├── sea-bae v0.2.0 (proc-macro)
│ ├── sea-query v0.30.7
│ ├── sea-query-binder v0.5.0
│ │ ├── sea-query v0.30.7 (*)

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 with the Rust reproducible example using gallery_media::Entity, left_join, and cursor_by(galleries::Column::Score), then trace how cursor_by builds the ORDER BY clause. Reproduce the MySQL error and verify the completed behavior uses the specified joined-table column without producing an unknown-column error.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, rust, sql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.