Skip to content

Add testcase that tickles bug in history#3082

Closed
tobias- wants to merge 2 commits into
ebean-orm:masterfrom
tobias-:findVersions_over_historied_historyless_historied
Closed

Add testcase that tickles bug in history#3082
tobias- wants to merge 2 commits into
ebean-orm:masterfrom
tobias-:findVersions_over_historied_historyless_historied

Conversation

@tobias-

@tobias- tobias- commented May 31, 2023

Copy link
Copy Markdown
Contributor

This PR demonstrates a bug in history where if you do findVersions() on a history object that references a non-versioned and then a versioned object again, a systime <@ null will be added to the query (postgres) which will of course always fail.

This proves the bug reported as #3083

…_historied_historyless_historied

Conflicts:
	ebean-test/src/test/java/org/tests/model/history/HistoryOneToOne.java
	ebean-test/src/test/java/org/tests/model/history/HistorylessOneToOne.java
@tobias- tobias- force-pushed the findVersions_over_historied_historyless_historied branch from ce97fe4 to 47b5ed1 Compare September 25, 2023 08:14
rob-bygrave added a commit that referenced this pull request Jun 30, 2026
…er history table

Bug (#3083): findVersions() on a @history root that joins to another @history entity bound the joined table's effective-date predicate with a null as-of timestamp → systime <@ null (Postgres) / sys_period_start <= null (H2) → zero rows.

  Fix (CQueryPredicates.bind(), +6 lines): when the as-of is null but there are history-view join predicates to bind (asOfTableCount > 0 — only ever true for findVersions/findVersionsBetween), default to the current timestamp. Semantics: all versions of the root, joined to related @history entities as they are now. The root table is untouched (still returns all versions).

  Test ported from #3082 :
   - New HistoryManyToOne entity (@history + @softdelete) — kept lean, dropped the PR's unneeded @onetomany
   - HistorylessOneToOne gains @manytoone HistoryManyToOne
   - New testVersionsWithHistoryOverHistoryless() — replaced the PR's always-failing placeholder (assertSql(...).contains("this does not exist")) with real assertions: count == 1 and SQL contains no asOf null bind
   - Left the existing @OnetoOne unchanged (the PR's optional = false tweak to the shared model wasn't needed)
@rbygrave

Copy link
Copy Markdown
Member

Replaced by 443b68a fixed in version 18.1.0

@rbygrave rbygrave closed this Jun 30, 2026
@rbygrave rbygrave added this to the 18.1.0 milestone Jun 30, 2026
@rbygrave rbygrave added the bug label Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants