Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » escaping table names
escaping table names [message #387030] Wed, 08 April 2009 12:50 Go to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
I've been trying to find the correct location to extend a database platform, in order to escape table names. Some databases have reserved tables, like user or group. Often such tables can still be used, if they are escaped in some way.

In this case a database schema written for MySql (which does not have a reserved user table) must be migrated to a Postgres. Postgres allows escaping the reserved table:

select * from user
vs
select * from "user"

The first one accesses the reserved table, the second accesses the custom table.

Now, I found the classes where SQL statements are constructed, but I cannot seem to find a place where the SQL identifiers or statements are "pulled through" a method in a DatabasePlatform to allow such tweaking (since DatabasePlatform is the only thing that is extendable from a ecliplink-user perspective).
Re: escaping table names [message #387041 is a reply to message #387030] Thu, 09 April 2009 13:12 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Automatically escaping table and column names would be a useful feature,
please log this as an enhancement request. I don't think you can do it
with just a DatabasePlatform, you would need to modify the DatabaseTable
object. It will be nice to have some persistence unit property to auto
escape all table and column names.

You can put the quotes in your mappings in the mean time. Instead of
setting the table's name to "Group" set it to "\"Group\"".

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: escaping table names [message #387073 is a reply to message #387041] Thu, 09 April 2009 14:19 Go to previous message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 807
Registered: July 2009
Senior Member
James wrote:
> Automatically escaping table and column names would be a useful feature,
> please log this as an enhancement request.

Bug 271782 has been added to the database


> I don't think you can do it
> with just a DatabasePlatform, you would need to modify the DatabaseTable
> object. It will be nice to have some persistence unit property to auto
> escape all table and column names.


True. Can this be automated? Do all databases use the same style of escaping (double quotes)? Doesn't MSAccess use square brackets? Anyhow, I assumed not and therefore intended to extend the database platform.


> You can put the quotes in your mappings in the mean time. Instead of
> setting the table's name to "Group" set it to "\"Group\"".

Only if that is a valid notation for all databases. The user table in postgres is just one scenario I may encounter.

Tom
Previous Topic:JDBC transaction isolation?
Next Topic:merge does not copy basic mappings
Goto Forum:
  


Current Time: Sun Dec 21 04:54:05 GMT 2014

Powered by FUDForum. Page generated in 0.01735 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software