summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-12-11 17:44:46 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-12-11 17:44:46 -0500
commitc691b4cbdf7424964f49ac2fd05057514e5856a3 (patch)
treea4d62e1d5c0e63c90fd1b5ce125928d7a86852c6 /test/sql
parentb88c54f95be3e3bc2e0923181d56862fa3fda9fa (diff)
downloadsqlalchemy-c691b4cbdf7424964f49ac2fd05057514e5856a3.tar.gz
- support for cdecimal
- add --with-cdecimal flag to tests, monkeypatches cdecimal in - fix mssql/pyodbc.py to not use private '_int' accessor in decimal conversion routines - pyodbc version 2.1.8 is needed for cdecimal in any case as previous versions also called '_int', 2.1.8 adds the same string logic as our own dialect, so that logic is skipped for modern pyodbc version - make the imports for "Decimal" consistent across the whole lib. not sure yet how we should be importing "Decimal" or what the best way forward is that would allow a clean user-invoked swap of cdecimal; for now, added docs suggesting a global monkeypatch - the two decimal libs are not compatible with each other so any chance of mixing produces serious issues. adding adapters to DBAPIs tedious and adds in-python overhead. suggestions welcome on how we should be doing Decimal/cdecimal.
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_functions.py4
-rw-r--r--test/sql/test_types.py26
2 files changed, 15 insertions, 15 deletions
diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py
index 396eaaf9b..0fb2ca5f7 100644
--- a/test/sql/test_functions.py
+++ b/test/sql/test_functions.py
@@ -10,7 +10,7 @@ from sqlalchemy import types as sqltypes
from test.lib import *
from sqlalchemy.sql.functions import GenericFunction
from test.lib.testing import eq_
-from decimal import Decimal as _python_Decimal
+from sqlalchemy.util.compat import decimal
from test.lib import testing
from sqlalchemy.databases import *
@@ -107,7 +107,7 @@ class CompileTest(TestBase, AssertsCompiledSQL):
((datetime.date(2007, 10, 5),
datetime.date(2005, 10, 15)), sqltypes.Date),
((3, 5), sqltypes.Integer),
- ((_python_Decimal(3), _python_Decimal(5)), sqltypes.Numeric),
+ ((decimal.Decimal(3), decimal.Decimal(5)), sqltypes.Numeric),
(("foo", "bar"), sqltypes.String),
((datetime.datetime(2007, 10, 5, 8, 3, 34),
datetime.datetime(2005, 10, 15, 14, 45, 33)), sqltypes.DateTime)
diff --git a/test/sql/test_types.py b/test/sql/test_types.py
index 73d99ac6a..3d9be543c 100644
--- a/test/sql/test_types.py
+++ b/test/sql/test_types.py
@@ -11,7 +11,7 @@ from sqlalchemy.databases import *
from test.lib.schema import Table, Column
from test.lib import *
from test.lib.util import picklers
-from decimal import Decimal
+from sqlalchemy.util.compat import decimal
from test.lib.util import round_decimal
@@ -1262,8 +1262,8 @@ class NumericTest(TestBase):
def test_numeric_as_decimal(self):
self._do_test(
Numeric(precision=8, scale=4),
- [15.7563, Decimal("15.7563"), None],
- [Decimal("15.7563"), None],
+ [15.7563, decimal.Decimal("15.7563"), None],
+ [decimal.Decimal("15.7563"), None],
)
def test_numeric_as_float(self):
@@ -1274,7 +1274,7 @@ class NumericTest(TestBase):
self._do_test(
Numeric(precision=8, scale=4, asdecimal=False),
- [15.7563, Decimal("15.7563"), None],
+ [15.7563, decimal.Decimal("15.7563"), None],
[15.7563, None],
filter_ = filter_
)
@@ -1282,15 +1282,15 @@ class NumericTest(TestBase):
def test_float_as_decimal(self):
self._do_test(
Float(precision=8, asdecimal=True),
- [15.7563, Decimal("15.7563"), None],
- [Decimal("15.7563"), None],
+ [15.7563, decimal.Decimal("15.7563"), None],
+ [decimal.Decimal("15.7563"), None],
filter_ = lambda n:n is not None and round(n, 5) or None
)
def test_float_as_float(self):
self._do_test(
Float(precision=8),
- [15.7563, Decimal("15.7563")],
+ [15.7563, decimal.Decimal("15.7563")],
[15.7563],
filter_ = lambda n:n is not None and round(n, 5) or None
)
@@ -1390,18 +1390,18 @@ class NumericRawSQLTest(TestBase):
@testing.fails_on('sqlite', "Doesn't provide Decimal results natively")
@testing.provide_metadata
def test_decimal_fp(self):
- t = self._fixture(metadata, Numeric(10, 5), Decimal("45.5"))
+ t = self._fixture(metadata, Numeric(10, 5), decimal.Decimal("45.5"))
val = testing.db.execute("select val from t").scalar()
- assert isinstance(val, Decimal)
- eq_(val, Decimal("45.5"))
+ assert isinstance(val, decimal.Decimal)
+ eq_(val, decimal.Decimal("45.5"))
@testing.fails_on('sqlite', "Doesn't provide Decimal results natively")
@testing.provide_metadata
def test_decimal_int(self):
- t = self._fixture(metadata, Numeric(10, 5), Decimal("45"))
+ t = self._fixture(metadata, Numeric(10, 5), decimal.Decimal("45"))
val = testing.db.execute("select val from t").scalar()
- assert isinstance(val, Decimal)
- eq_(val, Decimal("45"))
+ assert isinstance(val, decimal.Decimal)
+ eq_(val, decimal.Decimal("45"))
@testing.provide_metadata
def test_ints(self):