Skip to content

✨ Make websocket types of dbapi2 compatibilty shim PEP-249 compliant #146

Open
@JoepvandenHoven-Bluemine

Description

Summary

In the current implementation the dbapi2 types for the websocket driver are not 100% compliant.

Details

PEP-249 requires that each type_code matches one of the available dbapi2 types. This is not currently the case for BOOL, CHAR and GEOMETRY.

The function Binary(string) is also missing, though the best it could do is throw a NotImplemented exception.

Background & Context

If possible it would be best to comply with the standard as much a possible. Obviously this is difficult for BOOL and GEOMETRY which don't have a particularly good fit right now.

At the very least CHAR should be added, it is mentioned in PEP-249 as an example of a STRING type.

Adding a Binary(string) function even one that raises an exception, can't really hurt. It would prevent issues when someone imports functions that the PEP-249 standard claims should exist.

Not sure what is best for BOOL, perhaps pretend it's a number? I think int(bool) is least likely to cause issues. Converting to string may cause confusion if someone tries to use it in an if statement (since all non-empty strings are truthy).

For GEOMETRY I'd say it's string based, querying one from Exasol returns a string and inserting a string causes it to be converted to a GEOMETRY type.

References

https://peps.python.org/pep-0249/#type-objects-and-constructors

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureProduct feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions