diff options
author | Jason Kirtland <jek@discorporate.us> | 2008-07-15 19:40:08 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2008-07-15 19:40:08 +0000 |
commit | 8b12c8f1c2048a9ef6f19b66823bf6053efff565 (patch) | |
tree | 528de821fb080eaee04b077e25e2746150d2658f | |
parent | 1d37472fdd1e4091fe2d158a21b27043fc8626f9 (diff) | |
download | sqlalchemy-8b12c8f1c2048a9ef6f19b66823bf6053efff565.tar.gz |
- Removed 2.3 Decimal compat
-rw-r--r-- | lib/sqlalchemy/databases/firebird.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 2 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/types.py | 3 | ||||
-rw-r--r-- | lib/sqlalchemy/util.py | 14 | ||||
-rw-r--r-- | test/dialect/maxdb.py | 2 | ||||
-rw-r--r-- | test/sql/testtypes.py | 8 |
8 files changed, 14 insertions, 27 deletions
diff --git a/lib/sqlalchemy/databases/firebird.py b/lib/sqlalchemy/databases/firebird.py index aba834f64..53cd3a573 100644 --- a/lib/sqlalchemy/databases/firebird.py +++ b/lib/sqlalchemy/databases/firebird.py @@ -99,7 +99,7 @@ parameter when creating the queries:: """ -import datetime, re +import datetime, decimal, re from sqlalchemy import exc, schema, types as sqltypes, sql, util from sqlalchemy.engine import base, default @@ -126,7 +126,7 @@ class FBNumeric(sqltypes.Numeric): return None else: def process(value): - if isinstance(value, util.decimal_type): + if isinstance(value, decimal.Decimal): return float(value) else: return value diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 1aea72a96..5852b2c43 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -44,7 +44,7 @@ from sqlalchemy.sql import compiler, expression, operators as sqlops, functions from sqlalchemy.sql import compiler, expression, operators as sql_operators, functions as sql_functions from sqlalchemy.engine import default, base from sqlalchemy import types as sqltypes -from sqlalchemy.util import Decimal as _python_Decimal +from decimal import Decimal as _python_Decimal MSSQL_RESERVED_WORDS = set(['function']) diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 704abbe6d..a56e6ad79 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -153,7 +153,7 @@ Notes page on the wiki at http://www.sqlalchemy.org is a good resource for timely information affecting MySQL in SQLAlchemy. """ -import datetime, inspect, re, sys +import datetime, decimal, inspect, re, sys from array import array as _array from sqlalchemy import exc, log, schema, sql, util @@ -338,7 +338,7 @@ class MSNumeric(sqltypes.Numeric, _NumericType): def result_processor(self, dialect): if not self.asdecimal: def process(value): - if isinstance(value, util.decimal_type): + if isinstance(value, decimal.Decimal): return float(value) else: return value diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 9adade2a6..5d61b32ad 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -19,7 +19,7 @@ parameter when creating the queries:: postgres_returning=[empl.c.id, empl.c.salary]).execute().fetchall() """ -import random, re, string +import decimal, random, re, string from sqlalchemy import sql, schema, exc, util from sqlalchemy.engine import base, default @@ -55,7 +55,7 @@ class PGNumeric(sqltypes.Numeric): return None else: def process(value): - if isinstance(value, util.decimal_type): + if isinstance(value, decimal.Decimal): return float(value) else: return value diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 163a6d7c4..a03bf41bf 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -23,9 +23,10 @@ __all__ = [ 'TypeEngine', 'TypeDecorator', 'AbstractType', import inspect import datetime as dt +from decimal import Decimal as _python_Decimal from sqlalchemy import exc -from sqlalchemy.util import pickle, Decimal as _python_Decimal +from sqlalchemy.util import pickle import sqlalchemy.util as util NoneType = type(None) diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index ee2840cf5..9175e78f2 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -27,20 +27,6 @@ try: except ImportError: import pickle -try: - # Try the standard decimal for > 2.3 or the compatibility module - # for 2.3, if installed. - from decimal import Decimal - decimal_type = Decimal -except ImportError: - def Decimal(arg): - if Decimal.warn: - warn("True Decimal types not available on this Python, " - "falling back to floats.") - Decimal.warn = False - return float(arg) - Decimal.warn = True - decimal_type = float try: from operator import attrgetter diff --git a/test/dialect/maxdb.py b/test/dialect/maxdb.py index f0bcd00e1..c2daf8959 100644 --- a/test/dialect/maxdb.py +++ b/test/dialect/maxdb.py @@ -4,7 +4,7 @@ import testenv; testenv.configure_for_tests() import StringIO, sys from sqlalchemy import * from sqlalchemy import exc, sql -from sqlalchemy.util import Decimal +from decimal import Decimal from sqlalchemy.databases import maxdb from testlib import * diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py index 9694d3616..eaeac326b 100644 --- a/test/sql/testtypes.py +++ b/test/sql/testtypes.py @@ -1,3 +1,4 @@ +import decimal import testenv; testenv.configure_for_tests() import datetime, os, pickleable, re from sqlalchemy import * @@ -716,17 +717,16 @@ class NumericTest(TestBase, AssertsExecutionResults): (2, 3.5, 5.6, Decimal("12.4"), Decimal("15.75")), ] - @testing.emits_warning('True Decimal types not available') def test_decimal_fallback(self): - from sqlalchemy.util import Decimal # could be Decimal or float + from decimal import Decimal numeric_table.insert().execute(ncasdec=12.4, fcasdec=15.75) numeric_table.insert().execute(ncasdec=Decimal("12.4"), fcasdec=Decimal("15.75")) for row in numeric_table.select().execute().fetchall(): - assert isinstance(row['ncasdec'], util.decimal_type) - assert isinstance(row['fcasdec'], util.decimal_type) + assert isinstance(row['ncasdec'], decimal.Decimal) + assert isinstance(row['fcasdec'], decimal.Decimal) class IntervalTest(TestBase, AssertsExecutionResults): |