empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shaun Forbes (JIRA)" <empire-db-...@incubator.apache.org>
Subject [jira] [Commented] (EMPIREDB-209) Using a reserved word as a column alias in a select statement.
Date Fri, 29 Aug 2014 00:15:09 GMT

    [ https://issues.apache.org/jira/browse/EMPIREDB-209?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14114640#comment-14114640
] 

Shaun Forbes commented on EMPIREDB-209:
---------------------------------------

Hey,
I think you're right.

I think what it was is that I was migrating from SQL Server to Postgres at the same time that
I came across the issue with aliases needing to be quoted if they're reserved words, so I
may have gone down the wrong track with getIdentifierQuoteString(). I probably played around
with some sql statements trying to get them to work and then looked for a metadata method
that returned the characters that appears to match with what I saw.

I'm not convinced that getIdentifierQuoteString() wasn't intended for this purpose, but given
that "A JDBC compliant driver should always return double quotes", and double quotes appears
to work for all databases, it's a bit of a moot point, and appendElementName() would seem
to be an easier option.

Cheers,
Shaun

> Using a reserved word as a column alias in a select statement.
> --------------------------------------------------------------
>
>                 Key: EMPIREDB-209
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-209
>             Project: Empire-DB
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: empire-db-2.4.2
>            Reporter: Shaun Forbes
>            Priority: Minor
>              Labels: newbie
>
> I believe it's possible in sql to use a reserved word as an alias in a select statement
if it's correctly quoted (it is for the databases I've tested anyway).
> Checking for and quoting reserved word aliases does not currently appear to be implemented.
> To overcome this limitation I've added an method to the DBDatabaseDriver class to add
the alias and perform any required quoting and altered the DBAliasExpr class to delegate the
adding of the alias to the DBDatabaseDriver class.
> The character I'm using for quoting is determined from the getIdentifierQuoteString()
method of the database connection metadata class, and I've used the detectQuoteName(String
name) method in DBDatabaseDriver to determine if the alias needs to be quoted.
> Patches available if required.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message