google-code-export / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
Other
0 stars 0 forks source link

Getting constraint name from Postgres #214

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I noticed today while I perused the code that the Postgres provider does 
not do a good job getting constraint names.  It's assuming the name for a 
PRIMARY KEY ends with "_pkey".  This won't work.  Primary keys may be 
named anything you desire, having the "_pkey" suffix is merely an artifact 
of the constraint added by the pgAdmin GUI.  The following query should 
clue you in on what's necessary:

select constraint_name from information_schema.table_constraints where 
table_schema=@schema and table_name=@view and 
constraint_type='PRIMARY KEY'

I did some detective work to find this which might help you in the future as 
well.  I turn on SQL Statement logging for Postgres and then use the 
pgAdmin GUI to explore my DB.  All the queries that the GUI does will be 
logged and should allow you to figure out most anything schema related.

Thanks.
-Abe

Original issue reported on code.google.com by abe.gill...@gmail.com on 16 Mar 2010 at 3:57

GoogleCodeExporter commented 9 years ago
Thanks for pointing it out. It was marked with a todo in the code.

Original comment by anders...@gmail.com on 17 Mar 2010 at 11:08

GoogleCodeExporter commented 9 years ago
Glad I could help. Please keep up the great work; you've got a very impressive 
and 
extremely useful project going here.

Original comment by abe.gill...@gmail.com on 19 Mar 2010 at 5:37

GoogleCodeExporter commented 9 years ago
Hey, I fix it and another issues. You can download the source here:

http://code.google.com/p/dblinq2007/issues/detail?id=132#c2

Original comment by tos.oliv...@gmail.com on 1 Apr 2012 at 2:09

GoogleCodeExporter commented 9 years ago
Hey guys!

I ran into this problem too, but all the constraints are affected by this issue.

I did some refactoring to get this work, see the attached patch.

Dom

Original comment by kandrait...@gmail.com on 22 Sep 2012 at 2:00

Attachments: