]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fixes for MySQL
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 31 May 2009 22:03:44 +0000 (22:03 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 31 May 2009 22:03:44 +0000 (22:03 +0000)
lib/sqlalchemy/dialects/mysql/base.py
test/engine/ddlevents.py
test/testlib/engines.py

index cec9ade928fe61feeae6891a499fd193f2a6df6a..47ce09a86627ee9e1ec0d6f61a057cdca39be452 100644 (file)
@@ -1466,10 +1466,12 @@ class MySQLDDLCompiler(compiler.DDLCompiler):
                     (self.preparer.quote(self._validate_identifier(index.name, False), index.quote),
                      self.preparer.format_table(index.table))
 
-    def visit_drop_foreignkey(self, drop):
+    def visit_drop_constraint(self, drop):
         constraint = drop.element
-        return "ALTER TABLE %s DROP FOREIGN KEY %s" % \
+        is_fk = isinstance(constraint, sa_schema.ForeignKeyConstraint)
+        return "ALTER TABLE %s DROP %s%s" % \
                     (self.preparer.format_table(constraint.table),
+                    is_fk and "FOREIGN KEY " or "",
                      self.preparer.format_constraint(constraint))
 
 class MySQLTypeCompiler(compiler.GenericTypeCompiler):
@@ -1832,6 +1834,7 @@ class MySQLDialect(default.DefaultDialect):
         self._server_casing = self._detect_casing(connection)
         self._server_collations = self._detect_collations(connection)
         self._server_ansiquotes = self._detect_ansiquotes(connection)
+            
         if self._server_ansiquotes:
             self.preparer = MySQLANSIIdentifierPreparer
         else:
@@ -2068,6 +2071,7 @@ class MySQLDialect(default.DefaultDialect):
         row = self._compat_fetchone(
             connection.execute("SHOW VARIABLES LIKE 'sql_mode'"),
                                charset=self._connection_charset)
+
         if not row:
             mode = ''
         else:
@@ -2609,7 +2613,7 @@ class MySQLIdentifierPreparer(_MySQLIdentifierPreparer):
 
     def __init__(self, dialect):
         super(MySQLIdentifierPreparer, self).__init__(dialect, initial_quote="`")
-
+        
     def _escape_identifier(self, value):
         return value.replace('`', '``')
 
index dcb16c194ee648bb96be8252c95ebeba49b94f79..f5613f5a926cbf8a32e652c5721c39c644f375ca 100644 (file)
@@ -328,7 +328,7 @@ class DDLTest(TestBase, AssertsCompiledSQL):
 
         ddl = DDL('%(schema)s-%(table)s-%(fullname)s')
 
-        dialect = testing.db.dialect
+        dialect = self.mock_engine().dialect
         self.assert_compile(ddl.against(sane_alone), '-t-t', dialect=dialect)
         self.assert_compile(ddl.against(sane_schema), 's-t-s.t', dialect=dialect)
         self.assert_compile(ddl.against(insane_alone), '-"t t"-"t t"', dialect=dialect)
index 358b9db5f94b3ef5d1540d7864e6894f88211254..8a3acb6a9a8568bcbfd5ff836f720bdafdcb41cf 100644 (file)
@@ -131,7 +131,11 @@ def testing_engine(url=None, options=None):
     listeners.append(testing_reaper)
 
     engine = create_engine(url, **options)
-
+    
+    # may want to call this, results
+    # in first-connect initializers
+    #engine.connect()
+    
     return engine
 
 def utf8_engine(url=None, options=None):