print decimal as long if scale is zero

optimize numeric and decimal displaying

add unit test case for print simple decimal

close the cursor
This commit is contained in:
Hongjiang Zhang
2020-05-21 15:49:49 +08:00
parent ff60a141cb
commit cac40267fc
4 changed files with 38 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
create table customer (
"CUST_ID" INTEGER not null,
"USER_ID" DECIMAL(18,0) not null,
primary key ("CUST_ID")
);
+1
View File
@@ -0,0 +1 @@
insert into CUSTOMER (CUST_ID, USER_ID) values (1, 12345);
+13
View File
@@ -70,6 +70,7 @@ class IntegrationTestBase(object):
def tearDown(self):
cursor = self.conn.cursor()
cursor.execute("drop table ACCOUNT");
cursor.execute("drop table CUSTOMER");
self.conn.close()
def test_execute_and_fetch_no_data(self):
@@ -207,11 +208,21 @@ class IntegrationTestBase(object):
cursor.execute("select * from ACCOUNT")
self.assertEqual(cursor.rowcount, -1)
def test_simple_decimal_print(self):
cursor = self.conn.cursor()
cursor.execute("select * from CUSTOMER")
result = cursor.fetchall()
cursor.close()
exp = [(1, 12345)]
self.assertEqual(result, exp)
class SqliteTestBase(IntegrationTestBase):
def setUpSql(self):
self.sql_file(os.path.join(_THIS_DIR, 'data', 'create.sql'))
self.sql_file(os.path.join(_THIS_DIR, 'data', 'insert.sql'))
self.sql_file(os.path.join(_THIS_DIR, 'data', 'create_simple_decimal.sql'))
self.sql_file(os.path.join(_THIS_DIR, 'data', 'insert_simple_decimal.sql'))
def test_execute_type_blob(self):
cursor = self.conn.cursor()
@@ -275,6 +286,8 @@ class HsqldbTest(IntegrationTestBase, unittest.TestCase):
def setUpSql(self):
self.sql_file(os.path.join(_THIS_DIR, 'data', 'create_hsqldb.sql'))
self.sql_file(os.path.join(_THIS_DIR, 'data', 'insert.sql'))
self.sql_file(os.path.join(_THIS_DIR, 'data', 'create_simple_decimal.sql'))
self.sql_file(os.path.join(_THIS_DIR, 'data', 'insert_simple_decimal.sql'))
class PropertiesDriverArgsPassingTest(unittest.TestCase):