Skip to content

fix: ORDER BY id in _get_scalar_relation_map#24

Open
rafabench wants to merge 1 commit into
masterfrom
rb/order-by-id-scalar-relations
Open

fix: ORDER BY id in _get_scalar_relation_map#24
rafabench wants to merge 1 commit into
masterfrom
rb/order-by-id-scalar-relations

Conversation

@rafabench
Copy link
Copy Markdown

Summary

Without ORDER BY, SQLite is free to use a covering index for the scan and traverses rows in FK-value order — so the returned relation vector ends up shuffled relative to source-id order. Every other read in this file already orders explicitly; this one was the outlier.

Test plan

Without ORDER BY, SQLite was free to pick an index-driven scan when a
covering index existed on the FK column, traversing rows in FK-value
order and producing a shuffled relation vector. Every other read in
this file already orders by id; this one was the outlier.

Closes #23

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@raphasampaio
Copy link
Copy Markdown
Member

Is this for which model? @rafabench

@rafabench
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

read_scalar_relations returns labels in wrong order when a covering index exists on the FK column

2 participants