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.
Created attachment 135910 [details] Small test case
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.
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.
I applied this patch for FC5 and FC6.