long2ice / asyncmy

A fast asyncio MySQL/MariaDB driver with replication protocol support
https://github.com/long2ice/asyncmy
Apache License 2.0
230 stars 25 forks source link

Issue with fallback encoder in the escape_item() function #65

Closed Hardtack closed 1 year ago

Hardtack commented 1 year ago

Since the v0.2.5 release, I have noticed a problem with the fallback encoder in the escape_item() function of the library. Previously, if I provided a value that was not directly listed in the encoder list, escape_item() would fall back to the default encoder, encode_str(), and it worked correctly. However, after the commit referenced here, a type declaration was added for encode_str(), which caused it to fail during type checks and can no longer be used as a default encoder.

I encountered this issue when using the FakeDate class from the freezegun library. FakeDate wraps datetime.date objects and relies on the default encoder.

To help address this issue, I plan to create a pull request that includes a reproduction of the problem.