mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-09-25 11:32:07 +00:00
Fix #3848: exists() generates invalid scalar SQL on SQL Server and Oracle Query.exists() generated `select exists(<subquery>)`, which is valid on Postgres/H2/MySQL but rejected by SQL Server and Oracle since both only support EXISTS as a predicate, not as a directly selectable scalar boolean expression. ┃ ┃ Add DatabasePlatform.existsWithCaseWhen/existsFromClause capability flags and use them in CQueryBuilder.wrapSelectExists() to generate `select case when exists(<subquery>) then 1 else 0 end` on platforms that ┃ need it, with an additional ` from dual` suffix for Oracle (which requires ┃ a FROM clause on every select). CQueryExists reads the boolean result via ┃ ResultSet.getBoolean(1), which correctly interprets the resulting 0/1 int.