diff options
author | Michael Trier <mtrier@gmail.com> | 2009-01-17 20:57:18 +0000 |
---|---|---|
committer | Michael Trier <mtrier@gmail.com> | 2009-01-17 20:57:18 +0000 |
commit | 27c4e7aade7d98f909dfb362bead0e38528213eb (patch) | |
tree | 5e13d74ad05a52dc264cfe9a2c3f7a5aa216721d /test/dialect/mssql.py | |
parent | f5eca3933eb54c697fe6f9b9fb218a4d98f96c3f (diff) | |
download | sqlalchemy-27c4e7aade7d98f909dfb362bead0e38528213eb.tar.gz |
Corrected handling of large decimal values on mssql. Added more robust tests.
- Removed string manipulation on floats. Float types are now passed through
to mssql as is.
- Fixes #1280
Diffstat (limited to 'test/dialect/mssql.py')
-rwxr-xr-x | test/dialect/mssql.py | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/test/dialect/mssql.py b/test/dialect/mssql.py index b7bc9a609..f0b0bec76 100755 --- a/test/dialect/mssql.py +++ b/test/dialect/mssql.py @@ -473,32 +473,51 @@ class TypesTest(TestBase): def setUpAll(self): global numeric_table, metadata metadata = MetaData(testing.db) + + def tearDown(self): + metadata.drop_all() + + def test_decimal_notation(self): + import decimal numeric_table = Table('numeric_table', metadata, Column('id', Integer, Sequence('numeric_id_seq', optional=True), primary_key=True), - Column('numericcol', Numeric(asdecimal=False)) + Column('numericcol', Numeric(precision=38, scale=20, asdecimal=True)) ) metadata.create_all() - def tearDownAll(self): - metadata.drop_all() + try: + test_items = [decimal.Decimal(d) for d in '1500000.00000000000000000000', + '-1500000.00000000000000000000', '1500000', + '0.0000000000000000002', '0.2', '-0.0000000000000000002', + '156666.458923543', '-156666.458923543', '1', '-1', '1234', + '2E-12', '4E8', '3E-6', '3E-7', '4.1', '1E-1', '1E-2', '1E-3', + '1E-4', '1E-5', '1E-6', '1E-7', '1E-8'] + for value in test_items: + numeric_table.insert().execute(numericcol=value) + + for value in select([numeric_table.c.numericcol]).execute(): + self.assertTrue(value[0] in test_items, "%s not in test_items" % value[0]) - def tearDown(self): - numeric_table.delete().execute() + except Exception, e: + raise e - def test_decimal_e_notation(self): - from decimal import Decimal + def test_float(self): + float_table = Table('float_table', metadata, + Column('id', Integer, Sequence('numeric_id_seq', optional=True), primary_key=True), + Column('floatcol', Float()) + ) + metadata.create_all() try: - numeric_table.insert().execute(numericcol=Decimal('4.1')) - numeric_table.insert().execute(numericcol=Decimal('1E-1')) - numeric_table.insert().execute(numericcol=Decimal('1E-2')) - numeric_table.insert().execute(numericcol=Decimal('1E-3')) - numeric_table.insert().execute(numericcol=Decimal('1E-4')) - numeric_table.insert().execute(numericcol=Decimal('1E-5')) - numeric_table.insert().execute(numericcol=Decimal('1E-6')) - numeric_table.insert().execute(numericcol=Decimal('1E-7')) - numeric_table.insert().execute(numericcol=Decimal('1E-8')) - numeric_table.insert().execute(numericcol=10000) + test_items = [float(d) for d in '1500000.00000000000000000000', + '-1500000.00000000000000000000', '1500000', + '0.0000000000000000002', '0.2', '-0.0000000000000000002', + '156666.458923543', '-156666.458923543', '1', '-1', '1234', + '2E-12', '4E8', '3E-6', '3E-7', '4.1', '1E-1', '1E-2', '1E-3', + '1E-4', '1E-5', '1E-6', '1E-7', '1E-8'] + for value in test_items: + float_table.insert().execute(floatcol=value) + except Exception, e: raise e |