File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -320,18 +320,18 @@ def __read_new_decimal(self, column):
320
320
321
321
for i in range (0 , uncomp_integral ):
322
322
value = struct .unpack ('>i' , self .packet .read (4 ))[0 ] ^ mask
323
- res += str ( value )
323
+ res += '%09d' % value
324
324
325
325
res += "."
326
326
327
327
for i in range (0 , uncomp_fractional ):
328
328
value = struct .unpack ('>i' , self .packet .read (4 ))[0 ] ^ mask
329
- res += str ( value )
329
+ res += '%09d' % value
330
330
331
331
size = compressed_bytes [comp_fractional ]
332
332
if size > 0 :
333
333
value = self .packet .read_int_be_by_size (size ) ^ mask
334
- res += str ( value )
334
+ res += '%0*d' % ( comp_fractional , value )
335
335
336
336
return decimal .Decimal (res )
337
337
Original file line number Diff line number Diff line change @@ -58,6 +58,23 @@ def test_decimal_long_values(self):
58
58
event = self .create_and_insert_value (create_query , insert_query )
59
59
self .assertEqual (event .rows [0 ]["values" ]["test" ], Decimal ("42000.123456" ))
60
60
61
+ def test_decimal_long_values_1 (self ):
62
+ create_query = "CREATE TABLE test (\
63
+ test DECIMAL(20,10) \
64
+ )"
65
+ insert_query = "INSERT INTO test VALUES(9000000123.123456)"
66
+ event = self .create_and_insert_value (create_query , insert_query )
67
+ self .assertEqual (event .rows [0 ]["values" ]["test" ], Decimal ("9000000123.123456" ))
68
+
69
+ def test_decimal_long_values_2 (self ):
70
+ create_query = "CREATE TABLE test (\
71
+ test DECIMAL(20,10) \
72
+ )"
73
+ insert_query = "INSERT INTO test VALUES(9000000123.0000012345)"
74
+ event = self .create_and_insert_value (create_query , insert_query )
75
+ self .assertEqual (event .rows [0 ]["values" ]["test" ],
76
+ Decimal ("9000000123.0000012345" ))
77
+
61
78
def test_decimal_negative_values (self ):
62
79
create_query = "CREATE TABLE test (\
63
80
test DECIMAL(20,10) \
You can’t perform that action at this time.
0 commit comments