You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Mark Struberg (Jira)" <ji...@apache.org> on 2021/03/30 19:02:00 UTC

[jira] [Resolved] (OPENJPA-84) Escape sql reserved words in column names

     [ https://issues.apache.org/jira/browse/OPENJPA-84?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Struberg resolved OPENJPA-84.
----------------------------------
    Fix Version/s: 3.1.3
         Assignee: Mark Struberg
       Resolution: Fixed

> Escape sql reserved words in column names
> -----------------------------------------
>
>                 Key: OPENJPA-84
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-84
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: sql
>            Reporter: Roger Keays
>            Assignee: Mark Struberg
>            Priority: Major
>             Fix For: 3.1.3
>
>
> OpenJPA does not escape reserved words in SQL queries when they are used as column names. To escape a reserved name you just put it in quotes:
> INSERT INTO FB_PRIVILEGES (comment, inheritable, level, role, type, username, item_uuid) ...
> on oracle, becomes 
> INSERT INTO FB_PRIVILEGES ("comment", inheritable, "level", role, "type", username, item_uuid) ...
> Looking at the code in DBDictionary, it appears that the escaping is done for table and sequence names by appending a numeral to the name. There isn't really any good reason to do this instead of quoting the identifier.
> table.name identifiers would have to be escaped as "table"."name" if both table and name were reserved words.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)