aiochclient
aiochclient copied to clipboard
Library does not accept subtypes
https://github.com/maximdanilchenko/aiochclient/blob/463533cdf41540f05b86ca0a7d0f287ef1a12513/aiochclient/types.py#L456
The library looks up types in a map using type(value) and raises an exception if the type does not exist in the map. This means any type derived from those types cannot be passed to the library. This creates errors at runtime for derived types that cannot be caught by type checkers. A common example will be StrEnum values, which are a subtype of str.
It's better to use isinstance(value, tuple(PY_TYPES_MAPPING)) to check for compatible types, and ensure that the underlying connection to ClickHouse accepts the types.
I'll also note that bool is a subtype of int, and you may wish to add unit tests to ensure that bool values are sent to ClickHouse correctly, or you could end up with errors where True becomes 1, and so on. I haven't investigated thoroughly to know whether there are any problems with bool or not, I just thought I'd mention it in case it helps.
@maximdanilchenko I think its good idea to allow insert enum's and call .value for them before insert.
Without this option client always must call .value by himself for every enum value.
If its relevant i can do this.