]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
merge r4889, SQLite Float type, from 0.4 branch
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 2 Jul 2008 18:29:36 +0000 (18:29 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 2 Jul 2008 18:29:36 +0000 (18:29 +0000)
CHANGES
lib/sqlalchemy/databases/sqlite.py
test/sql/testtypes.py

diff --git a/CHANGES b/CHANGES
index 13ac302a15a48e882f6b6a5b6aa2982c135d0dea..5a193fbb3f141e8c8251ad43a211cb02edf00458 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -189,6 +189,11 @@ CHANGES
       that row request (so BufferedColumnRow is still needed, 
       but less so). [ticket:1062]
 
+- sqlite
+      - 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 4f1fa9da5b0d003da4eb9892096db88f42db688b..bbfb99d65a616ebd7597b1c034e6a51dc8f75e75 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 56bd614996b928f6e59b6ac3fa96388019a42edc..9694d36163e6366ce48e70417be50c6918b843e6 100644 (file)
@@ -263,9 +263,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'))