Bug 205894 - SQLObject does not determine Foreign Key dependencies
SQLObject does not determine Foreign Key dependencies
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: python-sqlobject (Show other bugs)
5
All Linux
medium Severity medium
: ---
: ---
Assigned To: Luke Macken
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-09-09 13:43 EDT by Toshio Kuratomi
Modified: 2016-09-19 22:37 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-09-11 22:51:01 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Small test case (325 bytes, text/x-python)
2006-09-09 13:43 EDT, Toshio Kuratomi
no flags Details
Patch to give SQLObject Foreignkey dependency intelligence (4.50 KB, patch)
2006-09-09 13:46 EDT, Toshio Kuratomi
no flags Details | Diff

  None (edit)
Description Toshio Kuratomi 2006-09-09 13:43:26 EDT
Description of problem:
I ran across this while using TurboGears and postgreSQL.

SQLObject does not determine what order it has to create or drop tables in. 
Instead, it appears to order alphabetically.  When using ForeignKey constraints
and a postgresql database, this can lead to problems as postgreSQL will raise an
exception when a foreign key references a table that does not exist yet.

Version-Release number of selected component (if applicable):
python-sqlobject-0.7.0-6

How reproducible:
Everytime.

Steps to Reproduce:
1. tg-admin quickstart
2. Download the attached model.py and replace the existing model.py with it
3. Edit dev.cfg to have a postgresql database URI
4. Create the empty postgresql database.
5. Run tg-admin sql create
  
Actual results:
Error is raised about non-existent table

Expected results:
All tables in the schema are created.

Additional info:
There are several upstream bugs reports in TurboGears and sqlobject trackers
that bear on this issue:
http://trac.turbogears.org/turbogears/ticket/279
http://sourceforge.net/tracker/index.php?func=detail&aid=1495030&group_id=74338&atid=540672

The attached patch is adapted from the turbogears ticket (I couldn't get the
patch there to apply directly so I regenerated it... Oddly, only the strip level
differs between my patch and the one attached to the bug but mine applies)

Using this patch, I can now create the database with the postgreSQL backend.
Comment 1 Toshio Kuratomi 2006-09-09 13:43:26 EDT
Created attachment 135910 [details]
Small test case
Comment 2 Toshio Kuratomi 2006-09-09 13:46:37 EDT
Created attachment 135911 [details]
Patch to give SQLObject Foreignkey dependency intelligence

This patch is adapted from the one in the TurboGears tracker.  I wasn't able to
find it in the upstream sqlobject tracker but I didn't search their mailing
list.  I've built it against the python-sqlobject devel branch and it resolves
the issue of creating tables in postgresql.
Comment 3 Toshio Kuratomi 2006-09-09 14:08:59 EDT
Found an SQLObject bug that addresses the issue even better than the previous one:
http://sourceforge.net/tracker/index.php?func=detail&aid=1432190&group_id=74338&atid=540672

I've commented in that bug report with links to the patch in the TurboGears tracker.
Comment 4 Luke Macken 2006-09-11 22:51:01 EDT
I applied this patch for FC5 and FC6.

Note You need to log in before you can comment on or make changes to this bug.