Skip to content

Add default ORDER BY id to Sequel model queries#5039

Open
philippthun wants to merge 1 commit intocloudfoundry:mainfrom
sap-contributions:sequel-default-order-by-id
Open

Add default ORDER BY id to Sequel model queries#5039
philippthun wants to merge 1 commit intocloudfoundry:mainfrom
sap-contributions:sequel-default-order-by-id

Conversation

@philippthun
Copy link
Copy Markdown
Member

@philippthun philippthun commented Apr 16, 2026

Adds a Sequel extension that hooks into fetch methods (all, each, first) to add ORDER BY id just before execution, ensuring deterministic query results for consistent API responses and reliable test behavior.

Skips ordering when incompatible (GROUP BY, compounds, DISTINCT ON, from_self) or unnecessary (explicit ORDER BY, no id column).

Remove now-redundant explicit order: :id from lifecycle data model associations. Consolidate diego/lrp_constants require into cloud_controller/diego/constants.

Introduce lightweight_db_spec_helper for Sequel extension specs that only need a bare DB connection without the full app bootstrap. Extract DbConnectionString to share connection logic between DbConfig and the
new helper. Switch default_order_by_id and query_length_logging specs to use it.

  • 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 marked this pull request as ready for review April 16, 2026 19:33
@philippthun philippthun force-pushed the sequel-default-order-by-id branch 2 times, most recently from 75b7198 to f39b294 Compare April 23, 2026 09:44
johha
johha previously approved these changes Apr 23, 2026
Adds a Sequel extension that hooks into fetch methods (all, each, first)
to add ORDER BY id just before execution, ensuring deterministic query
results for consistent API responses and reliable test behavior.

Skips ordering when incompatible (GROUP BY, compounds, DISTINCT ON,
from_self) or unnecessary (explicit ORDER BY, no id column).

Remove now-redundant explicit order: :id from lifecycle data model
associations. Consolidate diego/lrp_constants require into
cloud_controller/diego/constants.

Introduce lightweight_db_spec_helper for Sequel extension specs that
only need a bare DB connection without the full app bootstrap. Extract
DbConnectionString to share connection logic between DbConfig and the
new helper. Switch default_order_by_id and query_length_logging specs
to use it.
@philippthun philippthun force-pushed the sequel-default-order-by-id branch from eb79fd5 to c4ea2b2 Compare April 23, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants