]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add SLFloat type, which matches the SQLite REAL
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 2 Jul 2008 18:26:58 +0000 (18:26 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 2 Jul 2008 18:26:58 +0000 (18:26 +0000)
type affinity.  Previously, only SLNumeric was provided
which fulfills NUMERIC affinity, but that's not the
same as REAL.

CHANGES
lib/sqlalchemy/databases/sqlite.py
test/sql/testtypes.py

diff --git a/CHANGES b/CHANGES
index d9855939911617e8925bf78488bb9d36428095d8..82f8aff413ebdc5c0ff375ecbfe63a42ef7ae379 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -98,6 +98,10 @@ CHANGES
 
       [ticket:1090]
 
+    - add SLFloat type, which matches the SQLite REAL 
+      type affinity.  Previously, only SLNumeric was provided
+      which fulfills NUMERIC affinity, but that's not the 
+      same as REAL.
 
 0.4.6
 =====
index 040e23a4bd092311b073a81465a8bbc004194382..b4af462211867ca095df3f14b6a4390ce3f09708 100644 (file)
@@ -32,6 +32,19 @@ class SLNumeric(sqltypes.Numeric):
         else:
             return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length}
 
+class SLFloat(sqltypes.Float):
+    def bind_processor(self, dialect):
+        type_ = self.asdecimal and str or float
+        def process(value):
+            if value is not None:
+                return type_(value)
+            else:
+                return value
+        return process
+
+    def get_col_spec(self):
+        return "FLOAT"
+    
 class SLInteger(sqltypes.Integer):
     def get_col_spec(self):
         return "INTEGER"
@@ -153,7 +166,7 @@ colspecs = {
     sqltypes.CHAR: SLChar,
     sqltypes.Date: SLDate,
     sqltypes.DateTime: SLDateTime,
-    sqltypes.Float: SLNumeric,
+    sqltypes.Float: SLFloat,
     sqltypes.Integer: SLInteger,
     sqltypes.NCHAR: SLChar,
     sqltypes.Numeric: SLNumeric,
index 09a3702ee74c9583d21547db767d4df1c3e23233..b71017bd619a7613afd771b035c28819538f6840 100644 (file)
@@ -278,9 +278,12 @@ class ColumnsTest(TestBase, AssertsExecutionResults):
                           }
 
         db = testing.db
-        if testing.against('sqlite', 'oracle'):
+        if testing.against('oracle'):
             expectedResults['float_column'] = 'float_column NUMERIC(25, 2)'
 
+        if testing.against('sqlite'):
+            expectedResults['float_column'] = 'float_column FLOAT'
+            
         if testing.against('maxdb'):
             expectedResults['numeric_column'] = (
                 expectedResults['numeric_column'].replace('NUMERIC', 'FIXED'))