escaping table names [message #387030] |
Wed, 08 April 2009 08:50  |
Eclipse User |
|
|
|
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 #387073 is a reply to message #387041] |
Thu, 09 April 2009 10:19  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04315 seconds