[SQL-CVS] r1443 - in SQLObject/trunk/sqlobject: . tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2005-12-30 20:17:34
|
Author: phd
Date: 2005-12-30 20:17:27 +0000 (Fri, 30 Dec 2005)
New Revision: 1443
Modified:
SQLObject/trunk/sqlobject/main.py
SQLObject/trunk/sqlobject/tests/dbtest.py
SQLObject/trunk/sqlobject/tests/test_cyclic_reference.py
Log:
applyConstraints
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2005-12-28 12:15:26 UTC (rev 1442)
+++ SQLObject/trunk/sqlobject/main.py 2005-12-30 20:17:27 UTC (rev 1443)
@@ -1349,7 +1349,7 @@
dropTable = classmethod(dropTable)
def createTable(cls, ifNotExists=False, createJoinTables=True,
- createIndexes=True,
+ createIndexes=True, applyConstraints=True,
connection=None):
conn = connection or cls._connection
if ifNotExists and conn.tableExists(cls.sqlmeta.table):
@@ -1359,7 +1359,11 @@
cls.sqlmeta.send(events.CreateTableSignal, cls, connection,
extra_sql, post_funcs)
constraints = conn.createTable(cls)
- extra_sql.extend(constraints)
+ if applyConstraints:
+ for constraint in constraints:
+ conn.query(constraint)
+ else:
+ extra_sql.extend(constraints)
if createJoinTables:
cls.createJoinTables(ifNotExists=ifNotExists,
connection=conn)
@@ -1371,8 +1375,8 @@
return extra_sql
createTable = classmethod(createTable)
- def createTableSQL(cls, createJoinTables=True, connection=None,
- createIndexes=True):
+ def createTableSQL(cls, createJoinTables=True, createIndexes=True,
+ connection=None):
conn = connection or cls._connection
sql, constraints = conn.createTableSQL(cls)
if createJoinTables:
Modified: SQLObject/trunk/sqlobject/tests/dbtest.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/dbtest.py 2005-12-28 12:15:26 UTC (rev 1442)
+++ SQLObject/trunk/sqlobject/tests/dbtest.py 2005-12-30 20:17:27 UTC (rev 1443)
@@ -166,7 +166,7 @@
soClass._connection.query(sql)
else:
sql, extra_sql = soClass.createTableSQL()
- soClass.createTable()
+ soClass.createTable(applyConstraints=False)
all_extra.extend(extra_sql)
cls(tableName=soClass.sqlmeta.table,
createSQL=sql,
Modified: SQLObject/trunk/sqlobject/tests/test_cyclic_reference.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_cyclic_reference.py 2005-12-28 12:15:26 UTC (rev 1442)
+++ SQLObject/trunk/sqlobject/tests/test_cyclic_reference.py 2005-12-30 20:17:27 UTC (rev 1443)
@@ -32,11 +32,11 @@
TestCyclicReferenceB.dropTable(ifExists=True, cascade=True)
assert not conn.tableExists(TestCyclicReferenceB.sqlmeta.table)
- constraints = TestCyclicReferenceA.createTable(ifNotExists=True)
- print constraints
+ constraints = TestCyclicReferenceA.createTable(ifNotExists=True,
+ applyConstraints=False)
assert conn.tableExists(TestCyclicReferenceA.sqlmeta.table)
- constraints += TestCyclicReferenceB.createTable(ifNotExists=True)
- print constraints
+ constraints += TestCyclicReferenceB.createTable(ifNotExists=True,
+ applyConstraints=False)
assert conn.tableExists(TestCyclicReferenceB.sqlmeta.table)
for constraint in constraints:
|