summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/ddl.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-10-29 17:38:56 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-10-29 17:38:56 -0400
commite6a5ea8fa7d10078c8d3f1bf6cabc4399cac3e70 (patch)
tree316f3c5287a1389d214437dadb9c2dca0560410f /lib/sqlalchemy/engine/ddl.py
parent5d6376fbd5ca4103a26118a6fffd1e95be0d5161 (diff)
downloadsqlalchemy-e6a5ea8fa7d10078c8d3f1bf6cabc4399cac3e70.tar.gz
- [bug] Postgresql dialect memoizes that an ENUM of a
particular name was processed during a create/drop sequence. This allows a create/drop sequence to work without any calls to "checkfirst", and also means with "checkfirst" turned on it only needs to check for the ENUM once. [ticket:2311]
Diffstat (limited to 'lib/sqlalchemy/engine/ddl.py')
-rw-r--r--lib/sqlalchemy/engine/ddl.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/sqlalchemy/engine/ddl.py b/lib/sqlalchemy/engine/ddl.py
index 79958baae..d6fdaee2e 100644
--- a/lib/sqlalchemy/engine/ddl.py
+++ b/lib/sqlalchemy/engine/ddl.py
@@ -21,6 +21,7 @@ class SchemaGenerator(DDLBase):
self.tables = tables and set(tables) or None
self.preparer = dialect.identifier_preparer
self.dialect = dialect
+ self.memo = {}
def _can_create_table(self, table):
self.dialect.validate_identifier(table.name)
@@ -56,7 +57,8 @@ class SchemaGenerator(DDLBase):
metadata.dispatch.before_create(metadata, self.connection,
tables=collection,
- checkfirst=self.checkfirst)
+ checkfirst=self.checkfirst,
+ _ddl_runner=self)
for seq in seq_coll:
self.traverse_single(seq, create_ok=True)
@@ -66,14 +68,16 @@ class SchemaGenerator(DDLBase):
metadata.dispatch.after_create(metadata, self.connection,
tables=collection,
- checkfirst=self.checkfirst)
+ checkfirst=self.checkfirst,
+ _ddl_runner=self)
def visit_table(self, table, create_ok=False):
if not create_ok and not self._can_create_table(table):
return
table.dispatch.before_create(table, self.connection,
- checkfirst=self.checkfirst)
+ checkfirst=self.checkfirst,
+ _ddl_runner=self)
for column in table.columns:
if column.default is not None:
@@ -86,7 +90,8 @@ class SchemaGenerator(DDLBase):
self.traverse_single(index)
table.dispatch.after_create(table, self.connection,
- checkfirst=self.checkfirst)
+ checkfirst=self.checkfirst,
+ _ddl_runner=self)
def visit_sequence(self, sequence, create_ok=False):
if not create_ok and not self._can_create_sequence(sequence):
@@ -104,6 +109,7 @@ class SchemaDropper(DDLBase):
self.tables = tables
self.preparer = dialect.identifier_preparer
self.dialect = dialect
+ self.memo = {}
def visit_metadata(self, metadata):
if self.tables:
@@ -117,7 +123,8 @@ class SchemaDropper(DDLBase):
metadata.dispatch.before_drop(metadata, self.connection,
tables=collection,
- checkfirst=self.checkfirst)
+ checkfirst=self.checkfirst,
+ _ddl_runner=self)
for table in collection:
self.traverse_single(table, drop_ok=True)
@@ -127,7 +134,8 @@ class SchemaDropper(DDLBase):
metadata.dispatch.after_drop(metadata, self.connection,
tables=collection,
- checkfirst=self.checkfirst)
+ checkfirst=self.checkfirst,
+ _ddl_runner=self)
def _can_drop_table(self, table):
self.dialect.validate_identifier(table.name)
@@ -155,7 +163,8 @@ class SchemaDropper(DDLBase):
return
table.dispatch.before_drop(table, self.connection,
- checkfirst=self.checkfirst)
+ checkfirst=self.checkfirst,
+ _ddl_runner=self)
for column in table.columns:
if column.default is not None:
@@ -164,7 +173,8 @@ class SchemaDropper(DDLBase):
self.connection.execute(schema.DropTable(table))
table.dispatch.after_drop(table, self.connection,
- checkfirst=self.checkfirst)
+ checkfirst=self.checkfirst,
+ _ddl_runner=self)
def visit_sequence(self, sequence, drop_ok=False):
if not drop_ok and not self._can_drop_sequence(sequence):