diff options
| -rw-r--r-- | CHANGES | 5 | ||||
| -rw-r--r-- | lib/sqlalchemy/databases/sqlite.py | 15 | ||||
| -rw-r--r-- | test/sql/testtypes.py | 5 |
3 files changed, 23 insertions, 2 deletions
@@ -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 ===== diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py index 4f1fa9da5..bbfb99d65 100644 --- a/lib/sqlalchemy/databases/sqlite.py +++ b/lib/sqlalchemy/databases/sqlite.py @@ -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, diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py index 56bd61499..9694d3616 100644 --- a/test/sql/testtypes.py +++ b/test/sql/testtypes.py @@ -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')) |
