Bug 205894 - SQLObject does not determine Foreign Key dependencies
Summary: SQLObject does not determine Foreign Key dependencies
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-sqlobject
Version: 5
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Luke Macken
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-09-09 17:43 UTC by Toshio Kuratomi
Modified: 2016-09-20 02:37 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-09-12 02:51:01 UTC
Type: ---
Embargoed:


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

Description Toshio Kuratomi 2006-09-09 17:43:26 UTC
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 17:43:26 UTC
Created attachment 135910 [details]
Small test case

Comment 2 Toshio Kuratomi 2006-09-09 17:46:37 UTC
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 18:08:59 UTC
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-12 02:51:01 UTC
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.