Re: [SQLObject] Re: Postgres: DROP table CASCADE
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2004-11-29 18:28:12
|
Oleg Broytmann wrote: > On Mon, Nov 29, 2004 at 12:03:03PM -0600, Ian Bicking wrote: > >>Can you move the server version into a method (serverVersion()) > > > Certainly I can... but why? You'd like to ask the same version again > and again? > Or you want to ask for the version only one, but not in __init__? In > the latter case it'd be better to implemen it as a property. You could cache the result, but in many cases that query need never be run, so it shouldn't happen on instantiation. >>>PS. After fixing it I've got an amazing number of exceptions and >>>failures during the test. It seems no one has ran the test suite for >>>quite some time, at least on Postgres! >> >>I was just running it without problems. Actually there's a transaction >>problem that only occurs when I run all the tests in sequence, and I >>don't understand it. But otherwise it's fine. Maybe it's more problems >>with 7.2? > > > I think so. The first problem is > > ERROR: testClassCreate (__main__.AutoTest) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "test_sqlobject.py", line 700, in testClassCreate > class AutoTest(SQLObject): > File "/usr/local/lib/python2.3/site-packages/sqlobject/main.py", line 225, in __new__ > newClass.addColumnsFromDatabase() > File "/usr/local/lib/python2.3/site-packages/sqlobject/main.py", line 593, in addColumnsFromDatabase > for columnDef in conn.columnsFromSchema(cls._table, cls): > File "pgconnection.py", line 151, in columnsFromSchema > File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 218, in queryAll > return self._runWithConnection(self._queryAll, s) > File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 126, in _runWithConnection > val = meth(conn, *args) > File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 211, in _queryAll > self._executeRetry(conn, c, s) > File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 197, in _executeRetry > return cursor.execute(query) > ProgrammingError: ERROR: parser: parse error at or near "(" > > > SELECT pg_catalog.pg_get_constraintdef(oid) as condef > FROM pg_catalog.pg_constraint r > WHERE r.conrelid = 'auto_test'::regclass AND r.contype = 'f' I don't believe there's any "pg_catalog" in 7.2; I believe pg_catalog is a schema (a separate table/function namespace), and schemas weren't introduced until after 7.2. In that case, maybe just removing "pg_catalog." will fix it (if the version is 7.2). > And most other exceptions are, probably, the result of unclean exit from the method: > > ERROR: testGet (__main__.DeleteSelectTest) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "/usr/local/src/SQL/SQLObject-inheritance/tests/SQLObjectTest.py", line 144, in setUp > c.createTable(ifNotExists=True) > File "/usr/local/lib/python2.3/site-packages/sqlobject/main.py", line 1161, in createTable > conn.createTable(cls) > File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 349, in createTable > self.query(self.createTableSQL(soClass)) > File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 205, in query > return self._runWithConnection(self._query, s) > File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 126, in _runWithConnection > val = meth(conn, *args) > File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 202, in _query > self._executeRetry(conn, conn.cursor(), s) > File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 197, in _executeRetry > return cursor.execute(query) > ProgrammingError: ERROR: Relation 'test_s_o1_id_seq' already exists > > CREATE TABLE test_s_o1 ( > id SERIAL PRIMARY KEY, > passwd VARCHAR(10), > name_col VARCHAR(50) > ) That's must be something left over; generally I haven't had problems with that (the tests are supposed to clean up after themselves), but it could happen. > except for the only failure: > > FAIL: Raise an error if a class is defined more than once. > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "test_sqlobject.py", line 37, in testErrorOnDuplicateClassDefinition > self.assertEqual(str(err), "class Duplicate is already in the registry") > File "/usr/local/lib/python2.3/unittest.py", line 302, in failUnlessEqual > raise self.failureException, \ > AssertionError: "class Duplicate is already in the registry (other class is <class '__main__.Duplicate'>, from the module __main__ in test_sqlobject.py; attempted new class is <class '__main__.Duplicate'>, from the module __main__ in test_sqlobject.py)" != 'class Duplicate is already in the registry' I just fixed this one today, if you svn up it should be gone. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |