History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CASTOR-457
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Unassigned
Reporter: Sebastian Gil
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

Bug in postgres driver quotation

Created: 21/May/03 11:13 PM   Updated: 18/May/05 02:40 AM
Component/s: JDO
Affects Version/s:
Fix Version/s: None

Time Tracking:
Not Specified

Operating System: All
Platform: All

Bugzilla Id: 1317

 Description  « Hide
Class PostgreSQLFactory has invalid quoteName method. You can't use
any databse schema with it. So driver works only with databases
without schemas. Correct quotation should looks like.

public String quoteName( String name )
int index;

index = name.indexOf('.');
if (index > 0) {
String result = "";
int tmpIndex = 0;

while (index > 0) { result += name.substring(tmpIndex, index) + "\".\""; tmpIndex = index + 1; index = name.indexOf('.', tmpIndex); }
return '"' + result + name.substring(tmpIndex) + '"';

return '"' + name + '"';


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Martin Fuchs - 05/Nov/04 01:42 PM
Yes, the current PostgreSQLFactory.quoteName() function is not sufficent to
quote names with the three components schema name, table name and column name.
It should instead call the generic function genericFactory.doubleQuoteName()
like OracleFactory.quoteName() and SybaseFactor.quoteName():

public String quoteName( String name )

{ return doubleQuoteName( name ); }

Werner Guttmann - 28/Nov/04 11:16 AM
Created an attachment (id=791)
Initial patch based upon above comments.

I'd really appreciate if somebody familiar with postgreSQL could let us know
whether using schemes works as a result of this patch.

Pawel Pesz - 03/Dec/04 12:52 AM
I haven't actually tested the patch but the code in
GeneralFactory.doubleQuoteName looks fine to me. I'm a former co-worker of the
original submitter

Werner Guttmann - 03/Dec/04 02:15 AM
Pawel, would downloading the latest sources (from CVS), applying the patch,
building Castor and verifying whether it resolves the problem be an option for you ?

Werner Guttmann - 03/Dec/04 02:15 AM
More generally, can somebody please post a test case (incl. mapping file et
alias) that coudl be used to verify that things work ?

Pawel Pesz - 03/Dec/04 04:19 AM
All right, I'll try and do that. A test case should not be hard to come up with
but unfortunately I can't promise you I'll manage to find time to prepare it.

Werner Guttmann - 03/Dec/04 07:49 AM
If you wanted, I could send you a couple of files that I normally use to write a
test case, i.e.
  • a mapping file.
  • a JDO config file
  • A JUnit test case with at least one testXXX() method.
  • a SQL DDL file.

Let me know whether this would be of any use to you.

Pawel Pesz - 06/Dec/04 12:47 AM
Yes, it certainly will. I would really appreciate it.

Pawel Pesz - 07/Dec/04 08:24 AM
OK. I conducted tests on my code-base which includes 50+ classes and tables. All
table definitions use PostgreSQL schemas. The patch works for me just fine.

Pawel Pesz - 09/Dec/04 01:37 AM
I just sent a test case to Werner, based on his code. Thanks

Werner Guttmann - 09/Dec/04 02:31 AM
Patch applied as it. Will add test case anywhen later (but before 0.9.6 releae).