crate / crate-python

Python DB API client library for CrateDB, using HTTP.
https://cratedb.com/docs/python/
Apache License 2.0
79 stars 30 forks source link

Types: Adjust CrateJsonEncoder to cast `Decimal` values to Python `float` types #604

Open amotl opened 9 months ago

amotl commented 9 months ago

About

This patch may be needed to fix value marshalling behaviour for Decimal types. It is apparently needed to be compatible with PostgreSQL.

This came up when using the SQLAlchemy dialect on behalf of a Singer/Meltano database sink component, in order to satisfy the software tests, where both implementation and test cases have been derived from the corresponding PostgreSQL adapter.

Status

Not sure if it classifies as a bug, but indeed it feels like a bug if the driver deviates from the standard DBAPI/PostgreSQL behaviour. Based on further investigations, the patch needs to find the right slot in one way or another.

References

Backlog

seut commented 9 months ago

I think using a float won't work as a Decimal has a 128bit range and thus cannot fit into a float.

amotl commented 1 week ago

Is it applicable to adjust this patch to respect CrateDB's new NUMERIC data type, when possible?