Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » PostgreSQL Attribute Foreign Key --> Bug?
icon5.gif  PostgreSQL Attribute Foreign Key --> Bug? [message #17448] Fri, 15 August 2008 17:22 Go to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
I noticed that my foreign keys were not being created in my PostgreSQL database. So I copied a query from the Attributes script created by U++ and tried to run it manually. The query was:
alter table MYTABLE1 add constraint FK_MYTABLE1$MYT_ID foreign key (MYT_ID) references MYTABLE2.MYT_ID;

The error I received was something like:
"ERROR: schema mytable2 does not exist."
I changed the script line to:
alter table MYTABLE1 add constraint FK_MYTABLE1$MYT_ID foreign key (MYT_ID) references MYTABLE2(MYT_ID);

Note the paren () instead of dot/period.
And it worked...

I am using PostgreSQL 8.2.9
Re: PostgreSQL Attribute Foreign Key --> Bug? [message #17452 is a reply to message #17448] Fri, 15 August 2008 19:05 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 697
Registered: December 2005
Location: Budapest, Hungary
Contributor
Originally, I just copied that code from an other implementation.

You can fix this bug in PostgreSQLSchema.h
Re: PostgreSQL Attribute Foreign Key --> Bug? [message #17522 is a reply to message #17452] Tue, 19 August 2008 13:55 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
In order to keep similarity of .sch files across all databases, we would not want to change the syntax that to define a reference. If this is a true statement, then we would need some sort of additional macro that would take a character string "TABLE.COLUMN" and turn it into "TABLE(COLUMN)" for only postgresql (and any other databases that require this syntax).

What is the best way to go about this?

Can we have a PostgresqlSchema class extend the Schema class and override Attribute and InlineAttribute to perform the replacement?

[Updated on: Tue, 19 August 2008 14:17]

Report message to a moderator

Re: PostgreSQL Attribute Foreign Key --> Bug? [message #17540 is a reply to message #17522] Tue, 19 August 2008 20:43 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
For now, to make it usable, I added code to methods Attribute() and InlineAttribute() in SqlSchema.cpp that checks the dialect for PGSQL and modifies the text returned by Expand() to replace the TABLE.COLUMN with TABLE(COLUMN)...

This should be fixed in trunk though.
Re: PostgreSQL Attribute Foreign Key --> Bug? [message #17585 is a reply to message #17540] Thu, 21 August 2008 16:53 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
So, who needs write rights to PGSQL package? Smile

Mirek
Previous Topic: Connecting to multiple databases.
Next Topic: Count error
Goto Forum:
  


Current Time: Tue Apr 23 20:54:21 CEST 2024

Total time taken to generate the page: 0.04872 seconds