Author: test
Date: 2005-10-25 19:44:00 +0000 (Tue, 25 Oct 2005)
New Revision: 1137
Modified:
SQLObject/trunk/docs/News.txt
SQLObject/trunk/sqlobject/joins.py
SQLObject/trunk/sqlobject/main.py
SQLObject/trunk/sqlobject/manager/command.py
Log:
Fixed sqlobject-admin record with respect to new createTableSQL return values. Allow RelatedJoin objects to have a createRelatedTable keyword argument, to suppress the automatic creation of the join table.
Modified: SQLObject/trunk/docs/News.txt
===================================================================
--- SQLObject/trunk/docs/News.txt 2005-10-25 16:45:52 UTC (rev 1136)
+++ SQLObject/trunk/docs/News.txt 2005-10-25 19:44:00 UTC (rev 1137)
@@ -23,6 +23,12 @@
* Added ``TimeCol``.
+* ``RelatedJoin`` and ``SQLRelatedJoin`` objects have a
+ ``createRelatedTable`` keyword argument (default ``True``). If
+ ``False``, then the related table won't be automatically created;
+ instead you must manually create it (e.g., with explicit SQLObject
+ classes for the joins).
+
SQLObject 0.7.0
===============
Modified: SQLObject/trunk/sqlobject/joins.py
===================================================================
--- SQLObject/trunk/sqlobject/joins.py 2005-10-25 16:45:52 UTC (rev 1136)
+++ SQLObject/trunk/sqlobject/joins.py 2005-10-25 19:44:00 UTC (rev 1137)
@@ -154,9 +154,12 @@
def __init__(self,
otherColumn=None,
- intermediateTable=None, **kw):
+ intermediateTable=None,
+ createRelatedTable=True,
+ **kw):
self.intermediateTable = intermediateTable
self.otherColumn = otherColumn
+ self.createRelatedTable = createRelatedTable
SOMultipleJoin.__init__(self, **kw)
classregistry.registry(
self.soClass.sqlmeta.registry).addClassCallback(
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2005-10-25 16:45:52 UTC (rev 1136)
+++ SQLObject/trunk/sqlobject/main.py 2005-10-25 19:44:00 UTC (rev 1137)
@@ -1329,6 +1329,9 @@
def createJoinTables(cls, ifNotExists=False, connection=None):
conn = connection or cls._connection
for join in cls._getJoinsToCreate():
+ if not getattr(join, 'createRelatedTable', True):
+ # This join has requested not to be created
+ continue
if (ifNotExists and
conn.tableExists(join.intermediateTable)):
continue
@@ -1339,6 +1342,9 @@
conn = connection or cls._connection
sql = []
for join in cls._getJoinsToCreate():
+ if not getattr(join, 'createRelatedTable', True):
+ # This join has requested not to be created
+ continue
sql.append(conn._SO_createJoinTableSQL(join))
return '\n'.join(sql)
createJoinTablesSQL = classmethod(createJoinTablesSQL)
Modified: SQLObject/trunk/sqlobject/manager/command.py
===================================================================
--- SQLObject/trunk/sqlobject/manager/command.py 2005-10-25 16:45:52 UTC (rev 1136)
+++ SQLObject/trunk/sqlobject/manager/command.py 2005-10-25 19:44:00 UTC (rev 1137)
@@ -859,6 +859,12 @@
+ '_' + dbName + '.sql')
if sim:
continue
+ create, constraints = cls.createTableSQL()
+ if constraints:
+ constraints = '\n-- Constraints:\n%s\n' % (
+ '\n'.join(constraints))
+ else:
+ constraints = ''
files[fn] = ''.join([
'-- Exported definition from %s\n'
% time.strftime('%Y-%m-%dT%H:%M:%S'),
@@ -866,8 +872,9 @@
% (cls.__module__, cls.__name__),
'-- Database: %s\n'
% dbName,
- cls.createTableSQL().strip(),
- '\n'])
+ create.strip(),
+ '\n',
+ constraints])
last_version_dir = self.find_last_version()
if last_version_dir and not self.options.force_create:
if v > 1:
|