Author: rflosi
Date: 2005-11-02 18:24:51 +0000 (Wed, 02 Nov 2005)
New Revision: 1189
Modified:
SQLObject/branches/0.7-bugfix/docs/News.txt
SQLObject/branches/0.7-bugfix/sqlobject/joins.py
SQLObject/branches/0.7-bugfix/sqlobject/main.py
SQLObject/branches/0.7-bugfix/sqlobject/manager/command.py
Log:
merged r1136:1137 from trunk
Modified: SQLObject/branches/0.7-bugfix/docs/News.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/News.txt 2005-11-02 18:22:42 UTC (rev 1188)
+++ SQLObject/branches/0.7-bugfix/docs/News.txt 2005-11-02 18:24:51 UTC (rev 1189)
@@ -16,6 +16,12 @@
.. _psycopg2: http://initd.org/projects/psycopg2
+* ``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/branches/0.7-bugfix/sqlobject/joins.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/joins.py 2005-11-02 18:22:42 UTC (rev 1188)
+++ SQLObject/branches/0.7-bugfix/sqlobject/joins.py 2005-11-02 18:24:51 UTC (rev 1189)
@@ -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/branches/0.7-bugfix/sqlobject/main.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/main.py 2005-11-02 18:22:42 UTC (rev 1188)
+++ SQLObject/branches/0.7-bugfix/sqlobject/main.py 2005-11-02 18:24:51 UTC (rev 1189)
@@ -1328,6 +1328,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
@@ -1338,6 +1341,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/branches/0.7-bugfix/sqlobject/manager/command.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/manager/command.py 2005-11-02 18:22:42 UTC (rev 1188)
+++ SQLObject/branches/0.7-bugfix/sqlobject/manager/command.py 2005-11-02 18:24:51 UTC (rev 1189)
@@ -422,8 +422,7 @@
def config_from_egg(self, egg_spec, warn_no_sqlobject=True):
import pkg_resources
- pkg_resources.require(egg_spec)
- dist = pkg_resources.working_set.find(pkg_resources.Requirement(egg_spec))
+ dist = pkg_resources.get_distribution(egg_spec)
if not dist.has_metadata('sqlobject.txt'):
if warn_no_sqlobject:
print 'No sqlobject.txt in %s egg info' % egg_spec
@@ -837,6 +836,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'),
@@ -844,8 +849,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:
|