#882: tg-admin sql drop fails with postgresql
------------------------------+---------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone:
Component: TurboGears | Version: 0.9a6
Severity: normal | Keywords:
------------------------------+---------------------------------------------
When a model needs an order defined for creation, tg-admin sql drop
doesn't do the right thing:
Model.py:
{{{
from sqlobject import *
soClasses = ('Source','Content')
class Source(SQLObject):
name = UnicodeCol()
contents = MultipleJoin('Content')
class Content(SQLObject):
body = UnicodeCol()
source = ForeignKey('Source')
}}}
{{{
kremer:testing $ tg-admin sql create
Using database URI postgres://db:[EMAIL PROTECTED]/testing
kremer:testing $ tg-admin sql drop
Using database URI postgres://db:[EMAIL PROTECTED]/testing
Traceback (most recent call last):
File "/usr/local/bin/tg-admin", line 7, in ?
sys.exit(
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/TurboGears-0.9a6-py2.4.egg/turbogears/command/base.py",
line 275, in main
command.run()
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/TurboGears-0.9a6-py2.4.egg/turbogears/command/base.py",
line 134, in run
command.the_runner.run(sys.argv)
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/SQLObject-0.7.1dev_r1675-
py2.4.egg/sqlobject/manager/command.py", line 102, in run
runner.run()
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/SQLObject-0.7.1dev_r1675-
py2.4.egg/sqlobject/manager/command.py", line 233, in run
self.command()
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/SQLObject-0.7.1dev_r1675-
py2.4.egg/sqlobject/manager/command.py", line 604, in command
soClass.dropTable()
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/SQLObject-0.7.1dev_r1675-py2.4.egg/sqlobject/main.py", line
1311, in dropTable
conn.dropTable(cls.sqlmeta.table, cascade)
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/SQLObject-0.7.1dev_r1675-
py2.4.egg/sqlobject/postgres/pgconnection.py", line 157, in dropTable
self.query("DROP TABLE %s %s" % (tableName,
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/SQLObject-0.7.1dev_r1675-
py2.4.egg/sqlobject/dbconnection.py", line 305, in query
return self._runWithConnection(self._query, s)
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/SQLObject-0.7.1dev_r1675-
py2.4.egg/sqlobject/dbconnection.py", line 219, in _runWithConnection
val = meth(conn, *args)
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/SQLObject-0.7.1dev_r1675-
py2.4.egg/sqlobject/dbconnection.py", line 302, in _query
self._executeRetry(conn, conn.cursor(), s)
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/SQLObject-0.7.1dev_r1675-
py2.4.egg/sqlobject/dbconnection.py", line 297, in _executeRetry
return cursor.execute(query)
psycopg.ProgrammingError: ERROR: cannot drop table source because other
objects depend on it
HINT: Use DROP ... CASCADE to drop the dependent objects too.
DROP TABLE source
}}}
tg-admin sql drop should drop objects in the opposite order to creation.
(postgres8, OS X 10.4)
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/882>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---