apply patch by Jason Newton

This commit is contained in:
iElectric 2009-10-07 00:05:31 +02:00
parent 728a01577f
commit b7685663fc
3 changed files with 10 additions and 7 deletions

View File

@ -128,7 +128,7 @@ class ModelGenerator(object):
decls = ['from migrate.changeset import schema',
'meta = MetaData()']
for table in self.diff.tablesMissingInModel + \
self.diff.tablesMissingInDatabase + \
self.diff.tablesMissingInDatabase + \
self.diff.tablesWithDiff:
decls.extend(self.getTableDefn(table))

View File

@ -84,7 +84,7 @@ class SchemaDiff(object):
if modelName in self.excludeTables:
continue
reflectedTable = self.reflected_model.tables.get(modelName, None)
if reflectedTable:
if reflectedTable is not None:
# Table exists.
pass
else:
@ -96,14 +96,14 @@ class SchemaDiff(object):
if reflectedName in self.excludeTables:
continue
modelTable = self.model.tables.get(reflectedName, None)
if modelTable:
if modelTable is not None:
# Table exists.
# Find missing columns in database.
for modelCol in modelTable.columns:
databaseCol = reflectedTable.columns.get(modelCol.name,
None)
if databaseCol:
if databaseCol is not None:
pass
else:
self.storeColumnMissingInDatabase(modelTable, modelCol)
@ -114,7 +114,7 @@ class SchemaDiff(object):
# TODO: no test coverage here? (mrb)
modelCol = modelTable.columns.get(databaseCol.name, None)
if modelCol:
if modelCol is not None:
# Compare attributes of column.
modelDecl = \
get_column_specification(modelCol)

View File

@ -178,12 +178,15 @@ class Version(object):
SQL_FILENAME = re.compile(r'^(\d+)_([^_]+)_([^_]+).sql')
def _add_script_sql(self, path):
match = self.SQL_FILENAME.match(os.path.basename(path))
basename = os.path.basename(path)
match = self.SQL_FILENAME.match(basename)
if match:
version, dbms, op = match.group(1), match.group(2), match.group(3)
else:
raise exceptions.ScriptError("Invalid SQL script name %s" % path)
raise exceptions.ScriptError(
"Invalid SQL script name %s " % basename + \
"(needs to be ###_database_operation.sql)")
# File the script into a dictionary
self.sql.setdefault(dbms, {})[op] = script.SqlScript(path)