Skip to content

Commit 6a49d9d

Browse files
committed
CQL encode floats with repr to preserve precision.
1 parent e4c4c67 commit 6a49d9d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

cassandra/encoder.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Encoder(object):
6767

6868
def __init__(self):
6969
self.mapping = {
70-
float: self.cql_encode_object,
70+
float: self.cql_encode_float,
7171
bytearray: self.cql_encode_bytes,
7272
str: self.cql_encode_str,
7373
int: self.cql_encode_object,
@@ -138,6 +138,12 @@ def cql_encode_object(self, val):
138138
"""
139139
return str(val)
140140

141+
def cql_encode_float(self, val):
142+
"""
143+
Encode floats using repr to preserve precision
144+
"""
145+
return repr(val)
146+
141147
def cql_encode_datetime(self, val):
142148
"""
143149
Converts a :class:`datetime.datetime` object to a (string) integer timestamp

0 commit comments

Comments
 (0)