]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Firebird numeric type now checks for Decimal explicitly,
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 4 Jan 2011 02:11:12 +0000 (21:11 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 4 Jan 2011 02:11:12 +0000 (21:11 -0500)
lets float() pass right through, thereby allowing
special values such as float('inf'). [ticket:2012]

CHANGES
lib/sqlalchemy/dialects/firebird/base.py
lib/sqlalchemy/dialects/firebird/kinterbasdb.py
test/dialect/test_firebird.py

diff --git a/CHANGES b/CHANGES
index e5192769cae2b3b93a6aa03139782bfc18877bfa..50bcdce6b4d5035bf7d3102b16adba3d956cc299 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -158,6 +158,11 @@ CHANGES
     when using a non-period-decimal-point NLS_LANG setting.
     [ticket:1953].
 
+- firebird
+  - Firebird numeric type now checks for Decimal explicitly,
+    lets float() pass right through, thereby allowing 
+    special values such as float('inf'). [ticket:2012]
+
 - declarative
   - An error is raised if __table_args__ is not in tuple
     or dict format, and is not None.  [ticket:1972]
index 39e19de25a16ed09f4890ab6e4c0b7a9b40bb8ae..978f044084a76a7086853bcbba197622516772e2 100644 (file)
@@ -564,7 +564,7 @@ class FBDialect(default.DefaultDialect):
                 else:
                     coltype = BLOB()
             else:
-                coltype = coltype(row)
+                coltype = coltype()
 
             # does it have a default value?
             defvalue = None
index ad8d44262f4c1fecb06762e55932a6466636d203..73989097be3108fa78225b9fb225d35d66dda353 100644 (file)
@@ -48,11 +48,12 @@ __ http://kinterbasdb.sourceforge.net/dist_docs/usage.html#special_issue_concurr
 from sqlalchemy.dialects.firebird.base import FBDialect, \
                                     FBCompiler, FBExecutionContext
 from sqlalchemy import util, types as sqltypes
+from sqlalchemy.util.compat import decimal
 
 class _FBNumeric_kinterbasdb(sqltypes.Numeric):
     def bind_processor(self, dialect):
         def process(value):
-            if value is not None:
+            if isinstance(value, decimal.Decimal):
                 return str(value)
             else:
                 return value
@@ -78,7 +79,7 @@ class FBDialect_kinterbasdb(FBDialect):
     colspecs = util.update_copy(
         FBDialect.colspecs,
         {
-            sqltypes.Numeric:_FBNumeric_kinterbasdb
+            sqltypes.Numeric:_FBNumeric_kinterbasdb,
         }
 
     )
index e1c31087279fdb22bb55320f7cc60f2edcb27442..e7eb470016629d5e7a44a6b7bed1cf62e4c10932 100644 (file)
@@ -319,6 +319,20 @@ class CompileTest(TestBase, AssertsCompiledSQL):
         for type_, args, kw, res in columns:
             self.assert_compile(type_(*args, **kw), res)
 
+class TypesTest(TestBase):
+    __only_on__ = 'firebird'
+
+    @testing.provide_metadata
+    def test_infinite_float(self):
+        t = Table('t', metadata, 
+            Column('data', Float)
+        )
+        metadata.create_all()
+        t.insert().execute(data=float('inf'))
+        eq_(t.select().execute().fetchall(),
+            [(float('inf'),)]
+        )
+
 class MiscTest(TestBase):
 
     __only_on__ = 'firebird'