]> 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 f8421c26ce97169dd41baeec8687e2d88f162e77..6491cf7419da4fff823172d8a94fd0f63567aab3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -173,6 +173,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 de880171fb965887c7803cc6736db208046c65b2..b9f6e0b3e3a7f9c3ce89ddf80c7c473979326f48 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 ce708936b7ffc8989985292931128ff688005278..532a93ed0990eb8c9e1427269a6952a1154ea8fe 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'