Skip to content

Fix default_order_by_id for association loading#5089

Draft
philippthun wants to merge 1 commit intocloudfoundry:mainfrom
sap-contributions:fix-default-order-by-id-association-loading
Draft

Fix default_order_by_id for association loading#5089
philippthun wants to merge 1 commit intocloudfoundry:mainfrom
sap-contributions:fix-default-order-by-id-association-loading

Conversation

@philippthun
Copy link
Copy Markdown
Member

@philippthun philippthun commented May 5, 2026

The extension hooks into Dataset#all/each/first to inject ORDER BY id, but Sequel's PlaceholderLiteralizer bypasses these methods entirely. It pre-compiles SQL via Dataset#sql and calls with_sql_all directly, so associations loaded through this optimized path had no deterministic ordering.

Override placeholder_literalizer_loader to inject the ordering into the dataset before it gets compiled into a reusable SQL template.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@philippthun philippthun force-pushed the fix-default-order-by-id-association-loading branch from e6b21da to 6e670f0 Compare May 5, 2026 15:22
The extension hooks into Dataset#all/each/first to inject ORDER BY id,
but Sequel's PlaceholderLiteralizer bypasses these methods entirely. It
pre-compiles SQL via Dataset#sql and calls with_sql_all directly, so
associations loaded through this optimized path had no deterministic
ordering.

Override placeholder_literalizer_loader to inject the ordering into the
dataset before it gets compiled into a reusable SQL template.
@philippthun philippthun force-pushed the fix-default-order-by-id-association-loading branch from 6e670f0 to e770afa Compare May 5, 2026 16:05
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.

1 participant