Repository navigation
AAE-52887 Fix(audit): omit null precedence in timestamp DESC queries - #2850
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
eromano
marked this pull request as ready for review
November 7, 2026 08:15
playswag — API Coverage Report
Coverage by Tag
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🐢 Slow Tests Report🧪 Unit TestsThe following 20 unit test(s) took more than 5 seconds:
🏋️ Slowest Unit Test Classes (aggregated)The following 2 class(es) took more than 30 seconds in total:
🔗 Integration TestsThe following 20 integration test(s) took more than 5 seconds:
🏋️ Slowest Integration Test Classes (aggregated)The following 7 class(es) took more than 30 seconds in total:
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use timestamp DESC NULLS FIRST for the paged audit export so Hibernate renders plain ORDER BY timestamp DESC on PostgreSQL even with the global default_null_ordering=last. Move SQL assertions into a dedicated IT that covers both v2 search and export queries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
Production audit queries render
ORDER BY timestamp DESC NULLS LAST, e.g.:The shared SessionFactory sets
hibernate.order_by.default_null_ordering=lastglobally. A SpringSortwithNATIVEnull handling (e.g.Sort.by(DESC, "timestamp")) inherits that default, so Hibernate appendsNULLS LASTtoDESC.The remaining timestamp index is
audit_event_timestamp_idx(btree, ascending). PostgreSQL can scan it backward for plainDESC(equivalent toDESC NULLS FIRST), but not forDESC NULLS LAST, which forces a full sort.idx_audit_event_timestamp_desc_nulls_lastwas dropped by changelog 23.Fix
AuditEventsAdminService.exportAuditsBetweenDates(source of theBETWEENquery above) now usesSort.Order.desc("timestamp").nullsFirst(), same as the v2 defaults from AAE-52887 Fix audit service endpoint to handle timestamp sorting correctly #2713/AAE-52887 Fix remaining NULLS LAST timestamp ordering on audit event queries #2719.NullOrdering.GREATEST), Hibernate 7 treatsDESC + NULLS FIRSTas the database default and does not render any null-precedence clause, so the SQL becomes plainORDER BY timestamp DESC. No new index is needed.Tests
AuditEventsTimestampOrderingSqlIT: renders SQL withPostgreSQLDialect+default_null_ordering=lastand captures statements via a HibernateStatementInspector. Asserts the v2 search and exportBETWEENqueries containorder by ...timestamp descand nonulls.AuditEventsAdminServiceTest: export requeststimestamp DESC NULLS_FIRST.