[prev in list] [next in list] [prev in thread] [next in thread] 

List:       castor-dev
Subject:    [castor-dev] Castor JDO 0.9.4.3 and PostgreSQL 7.3 Quoting Issue
From:       Dieter Wimberger <dieter () wimpi ! net>
Date:       2003-02-25 23:00:05
[Download RAW message or body]

Hi all,

I have been upgrading to PostgreSQL 7.3, and I realized that there exists an
issue with the quoting and case sensitivity.

I have been running into a problem using Castor with following error
message: 
ERROR:  Relation "xy" does not exist

This might come from a table name in the mapping file with uppercase letters
like Preferences, which is obviously created all in lowercase in the
database (e.g. preferences) on the database, and cannot be retrieved with
the quoted name generated by the PostgreSQLFactory
(castor-0.9.4.3/src/main/org/exolab/castor/jdo/drivers).

I investigated and realized that the psql commandline tool shows the same
behavior:
mydb=# select * from "Preferences";
ERROR:  Relation "Preferences" does not exist

While the unquoted version works in any case.

Now, this might be a PostgreSQL issue/bug or a new "Feature", however, I
have not been able to figure it out, and I am better on the java side, so I
patched Castor respectively the PostgreSQLFactory as follows:

--- PostgreSQLFactory.java.orig Tue Feb 25 16:39:00 2003
+++ PostgreSQLFactory.java      Sun Feb 23 16:27:39 2003
@@ -91,12 +91,15 @@

     public String quoteName( String name )
     {
+        return name;
+        /*
         int index;

         index = name.indexOf( '.' );
         if ( index > 0 )
             return "\"" + name.substring( 0, index ) + "\".\"" +
name.substring( index + 1 ) + "\"";
         return '"' + name + '"';
+        */
     }

Note that this will most likely break Castor working with older PostgreSQL
database versions (7.1 and 7.2?). Thus it would be great to figure out what
can be done to fix this problem and make Castor work with both.

An alternative approach that works would be making all names lowercase, but
I am not sure if this will work for older versions or not.

Regards,
Dieter

PS: I would like to continue to deliver one mapping file for more then one
databases. So far, it was possible to switch between for example MySQL and
Postgres without troubles, using the same mapping files.

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
minimalist@exolab.org with a subject of:
	unsubscribe castor-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic