]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Firebird - the "implicit_returning" flag on create_engine() is
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 16 Mar 2011 15:22:28 +0000 (11:22 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 16 Mar 2011 15:22:28 +0000 (11:22 -0400)
honored if set to False.  [ticket:2083]

CHANGES
lib/sqlalchemy/dialects/firebird/base.py
test/sql/test_returning.py

diff --git a/CHANGES b/CHANGES
index f2a6c797816ffac8646e4eb98ca24d1d2c0d15e7..f31af1d914c91304143c6a4cdb2598ede28ff404 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -487,12 +487,16 @@ CHANGES
 
 - informix
 
-- Added RESERVED_WORDS informix dialect. [ticket:2092]
+  - Added RESERVED_WORDS informix dialect. [ticket:2092]
 
 - mysql
   - oursql dialect accepts the same "ssl" arguments in 
     create_engine() as that of MySQLdb.  [ticket:2047]
 
+- firebird
+  - The "implicit_returning" flag on create_engine() is
+    honored if set to False.  [ticket:2083]
+
 - declarative
   - Added an explicit check for the case that the name
     'metadata' is used for a column attribute on a 
index 4b8df55bb1e6deb8e9575ba3240eddf1568c3ae9..5f07b57b761aed8bbba693b7ecd591841cfccfcb 100644 (file)
@@ -362,7 +362,6 @@ class FBDialect(default.DefaultDialect):
     requires_name_normalize = True
     supports_empty_insert = False
 
-
     statement_compiler = FBCompiler
     ddl_compiler = FBDDLCompiler
     preparer = FBIdentifierPreparer
@@ -393,8 +392,9 @@ class FBDialect(default.DefaultDialect):
             self.colspecs = {
                 sqltypes.DateTime: sqltypes.DATE
             }
-        else:
-            self.implicit_returning = True
+
+        self.implicit_returning = self._version_two  and \
+                            self.__dict__.get('implicit_returning', True)
 
     def normalize_name(self, name):
         # Remove trailing spaces: FB uses a CHAR() type,
index 2a8e6fc2f0cbcfde43d26e9cac5e34136775c241..8c4e2ac3c667b9a8ae31d2470fc12f786e65c3e3 100644 (file)
@@ -5,7 +5,7 @@ from test.lib.schema import Table, Column
 from sqlalchemy.types import TypeDecorator
 
 class ReturningTest(TestBase, AssertsExecutionResults):
-    __unsupported_on__ = ('sqlite', 'mysql', 'maxdb', 'sybase', 'access')
+    __requires__ = 'returning',
 
     def setup(self):
         meta = MetaData(testing.db)
@@ -142,7 +142,7 @@ class ReturningTest(TestBase, AssertsExecutionResults):
         eq_(result2.fetchall(), [(2,False),])
 
 class SequenceReturningTest(TestBase):
-    __unsupported_on__ = ('sqlite', 'mysql', 'maxdb', 'sybase', 'access', 'mssql')
+    __requires__ = 'returning',
 
     def setup(self):
         meta = MetaData(testing.db)
@@ -165,7 +165,7 @@ class SequenceReturningTest(TestBase):
 class KeyReturningTest(TestBase, AssertsExecutionResults):
     """test returning() works with columns that define 'key'."""
 
-    __unsupported_on__ = ('sqlite', 'mysql', 'maxdb', 'sybase', 'access')
+    __requires__ = 'returning',
 
     def setup(self):
         meta = MetaData(testing.db)
@@ -191,3 +191,33 @@ class KeyReturningTest(TestBase, AssertsExecutionResults):
         assert row[table.c.foo_id] == row['id'] == 1
 
 
+class ImplicitReturningFlag(TestBase):
+    def test_flag_turned_off(self):
+        e = engines.testing_engine(options={'implicit_returning':False})
+        assert e.dialect.implicit_returning is False
+        c = e.connect()
+        assert e.dialect.implicit_returning is False
+
+    def test_flag_turned_on(self):
+        e = engines.testing_engine(options={'implicit_returning':True})
+        assert e.dialect.implicit_returning is True
+        c = e.connect()
+        assert e.dialect.implicit_returning is True
+
+    def test_flag_turned_default(self):
+        supports = [False]
+        def go():
+            supports[0] = True
+        testing.requires.returning(go)()
+        e = engines.testing_engine()
+
+        # starts as False.  This is because all of Firebird,
+        # Postgresql, Oracle, SQL Server started supporting RETURNING
+        # as of a certain version, and the flag is not set until
+        # version detection occurs.  If some DB comes along that has 
+        # RETURNING in all cases, this test can be adjusted.
+        assert e.dialect.implicit_returning is False 
+
+        # version detection on connect sets it
+        c = e.connect()
+        assert e.dialect.implicit_returning is supports[0]