rzo1 opened a new pull request, #317:
URL: https://github.com/apache/openjpa/pull/317

   https://issues.apache.org/jira/browse/OPENJPA-3094
   
   `DBDictionary.toBulkOperation()` only wrote a bulk DELETE/UPDATE directly on 
the table when `allowsAliasInBulkClause` is true. PostgreSQL and Derby set it 
to false (PostgreSQL rejects alias-qualified columns in `UPDATE ... SET`), so a 
single-table statement became `... WHERE ID IN (SELECT DISTINCT t0.ID FROM 
<table> t0 WHERE ...)`. The new dictionary property 
`allowsTargetAliasInBulkClause` allows an alias on the target table that only 
WHERE uses, while SET columns stay unqualified. It is set for PostgreSQL and 
Derby. Joins, secondary tables, subqueries in WHERE and SQL Server keep the 
subquery.
   
   ```
   before: DELETE FROM ORDERS WHERE ID IN (SELECT DISTINCT t0.ID FROM ORDERS t0 
WHERE (t0.ID >= ? AND t0.ID <= ?))
   after:  DELETE FROM ORDERS t0 WHERE (t0.ID >= ? AND t0.ID <= ?)
   ```
   
   Tests (Derby): new `TestBulkSingleTableRange` (delete and update by range, 
update from own columns, single-table subclass, join keeps the subquery), 
asserting the exact SQL for Derby and PostgreSQL. The full 
openjpa-persistence-jdbc suite passes on Derby; PostgreSQL runs in CI.
   
   Draft: the TCK runs on this branch first.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to