-
-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Hi,
Seems that RethinkDB is converting float value of 0.0 to integer value of 0.
In my scenario the problem is that python dictionaries are saved in RethinkDB and upon retrieval this (undesired) conversion happens. Some of the upstream systems check for the type of the field (float is expected but an int is received).
Is there a way to avoid this conversion? Is it a feature or a bug?
task_info = {'a': 0.0, 'b': +0.0, 'c': -0.0}
ta = task_info['a']
tb = task_info['b']
tc = task_info['c']
print(f'ta - {type(ta)}, {ta}')
print(f'tb - {type(tb)}, {tb}')
print(f'tc - {type(tc)}, {tc}')
result = r.table(table).insert(task_info).run(connection)
task_id = result['generated_keys'][0]
Output is:
ta - <class 'float'>, 0.0
tb - <class 'float'>, 0.0
tc - <class 'float'>, -0.0
document = r.table(table).get(task_id).run(connection)
print(document)
a = document['a']
b = document['b']
c = document['c']
print(f'a - {type(a)}, {a}')
print(f'b - {type(b)}, {b}')
print(f'b - {type(c)}, {c}')
Output is:
{'a': 0, 'b': 0, 'c': -0.0, 'id': 'd8df59a5-330f-4cd0-84ac-394b70a05b9d'}
a - <class 'int'>, 0
b - <class 'int'>, 0
b - <class 'float'>, -0.0
Using the latest container (rethinkdb 2.4.1~0buster)
Python client version (rethinkdb==2.4.8)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers