You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Maxim Solodovnik (Jira)" <ji...@apache.org> on 2026/08/20 07:42:00 UTC

[jira] [Created] (OPENJPA-2960) NULLS FIRST/LAST string rewrite breaks on commas, triplicated

Maxim Solodovnik created OPENJPA-2960:
-----------------------------------------

             Summary: NULLS FIRST/LAST string rewrite breaks on commas, triplicated
                 Key: OPENJPA-2960
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2960
             Project: OpenJPA
          Issue Type: Sub-task
          Components: jpa
    Affects Versions: 4.2.0
            Reporter: Maxim Solodovnik
            Assignee: Romain Manni-Bucau
             Fix For: 4.2.0


Discussion thread: https://github.com/apache/openjpa/pull/144#discussion_r3683001538)


**(high)** The NULLS FIRST/LAST emulation finds the last order term with `sql.lastIndexOf(", ", termDirStart)`, so any ORDER BY expression containing a comma (e.g. `COALESCE(t0.x, 0) DESC`) is split mid-argument-list and the rewrite produces corrupt SQL; duplicating the expression also duplicates `?` markers without duplicating bound parameters. The block is triplicated in MariaDBDictionary (~575) and SQLServerDictionary (~484) - can it be extracted to a shared helper operating on the order term before it is appended to the buffer instead of string-parsing it back out?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)