File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Original file line number Diff line number Diff line change @@ -82,6 +82,8 @@ def Thing2Literal(o, d):
82
82
that method when the connection is created."""
83
83
return string_literal (o , d )
84
84
85
+ def Decimal2Literal (o , d ):
86
+ return format (o , 'f' )
85
87
86
88
def char_array (s ):
87
89
return array .array ('c' , s )
@@ -142,6 +144,6 @@ def quote_tuple(t, d):
142
144
from decimal import Decimal
143
145
conversions [FIELD_TYPE .DECIMAL ] = Decimal
144
146
conversions [FIELD_TYPE .NEWDECIMAL ] = Decimal
145
- conversions [Decimal ] = Thing2Str
147
+ conversions [Decimal ] = Decimal2Literal
146
148
except ImportError :
147
149
pass
Original file line number Diff line number Diff line change @@ -202,6 +202,12 @@ def generator(row,col):
202
202
('col1 DECIMAL(5,2)' ,),
203
203
generator )
204
204
205
+ val = Decimal ('1.11111111111111119E-7' )
206
+ self .cursor .execute ('SELECT %s' , (val ,))
207
+ result = self .cursor .fetchone ()[0 ]
208
+ self .assertEqual (result , val )
209
+ self .assertIsInstance (result , Decimal )
210
+
205
211
self .cursor .execute ('SELECT %s + %s' , (Decimal ('0.1' ), Decimal ('0.2' )))
206
212
result = self .cursor .fetchone ()[0 ]
207
213
self .assertEqual (result , Decimal ('0.3' ))
You can’t perform that action at this time.
0 commit comments