You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Patrick Linskey (JIRA)" <ji...@apache.org> on 2007/03/01 02:18:51 UTC

[jira] Updated: (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 ]

Patrick Linskey updated OPENJPA-84:
-----------------------------------

    Fix Version/s: 1.0.0

> 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
>             Fix For: 1.0.0
>
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


RE: [jira] Updated: (OPENJPA-84) Escape sql reserved words in column names

Posted by Patrick Linskey <pl...@bea.com>.
> Can you ask OpenJPA to quote ALL identifiers for a particular
> data source?

Not currently, but certainly would be useful once we add quoting
support.

> You might have an identifier (with some databases) that is 
> declared as "a", but if you access it without quotes in a query
> it will be auto-uppercased to A and won't match.

You can tell OpenJPA whether or not the database is case-sensitive. This
is configured in the DBDictionary, and can be fine-tuned by the user.
IOW, you can control whether or not OpenJPA auto-uppercases things.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: Evan Ireland [mailto:eireland@sybase.com] 
> Sent: Thursday, March 01, 2007 11:32 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: [jira] Updated: (OPENJPA-84) Escape sql reserved 
> words in column names
> 
> Patrick,
> 
> Can you ask OpenJPA to quote ALL identifiers for a particular
> data source?
> 
> You might have an identifier (with some databases) that is 
> declared as "a", but if you access it without quotes in a query
> it will be auto-uppercased to A and won't match.
> 
> Rather than a special case for SQL reserved words, the ability
> to quote all identifiers or quote none is generally more useful.
> 
> > -----Original Message-----
> > From: Patrick Linskey (JIRA) [mailto:jira@apache.org] 
> > Sent: Thursday, 1 March 2007 2:19 p.m.
> > To: open-jpa-dev@incubator.apache.org
> > Subject: [jira] Updated: (OPENJPA-84) Escape sql reserved 
> > words in column names
> > 
> > 
> >      [ 
> > https://issues.apache.org/jira/browse/OPENJPA-84?page=com.atla
> > ssian.jira.plugin.system.issuetabpanels:all-tabpanel ]
> > 
> > Patrick Linskey updated OPENJPA-84:
> > -----------------------------------
> > 
> >     Fix Version/s: 1.0.0
> > 
> > > 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
> > >             Fix For: 1.0.0
> > >
> > >
> > > 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 is automatically generated by JIRA.
> > -
> > You can reply to this email to add a comment to the issue online.
> > 
> > 
> 
> 

RE: [jira] Updated: (OPENJPA-84) Escape sql reserved words in column names

Posted by Evan Ireland <ei...@sybase.com>.
Patrick,

Can you ask OpenJPA to quote ALL identifiers for a particular
data source?

You might have an identifier (with some databases) that is 
declared as "a", but if you access it without quotes in a query
it will be auto-uppercased to A and won't match.

Rather than a special case for SQL reserved words, the ability
to quote all identifiers or quote none is generally more useful.

> -----Original Message-----
> From: Patrick Linskey (JIRA) [mailto:jira@apache.org] 
> Sent: Thursday, 1 March 2007 2:19 p.m.
> To: open-jpa-dev@incubator.apache.org
> Subject: [jira] Updated: (OPENJPA-84) Escape sql reserved 
> words in column names
> 
> 
>      [ 
> https://issues.apache.org/jira/browse/OPENJPA-84?page=com.atla
> ssian.jira.plugin.system.issuetabpanels:all-tabpanel ]
> 
> Patrick Linskey updated OPENJPA-84:
> -----------------------------------
> 
>     Fix Version/s: 1.0.0
> 
> > 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
> >             Fix For: 1.0.0
> >
> >
> > 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 is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
> 
>