Commits

Mike Bayer  committed aded53a

- Firebird - the "implicit_returning" flag on create_engine() is
honored if set to False. [ticket:2083]

  • Participants
  • Parent commits 3c37e23

Comments (0)

Files changed (3)

 
 - 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 

File lib/sqlalchemy/dialects/firebird/base.py

     requires_name_normalize = True
     supports_empty_insert = False
 
-
     statement_compiler = FBCompiler
     ddl_compiler = FBDDLCompiler
     preparer = FBIdentifierPreparer
             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,

File test/sql/test_returning.py

 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)
         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)
 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)
         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]