Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-84

Escape sql reserved words in column names

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.2.0
    • sql
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              struberg Mark Struberg
              rogerkeays Roger Keays
              Votes:
              5 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: