-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQLlite converter recipes result in TypeError #99392
Comments
(cherry picked from commit dfc1b17) Co-authored-by: naglis <[email protected]>
(cherry picked from commit dfc1b17) Co-authored-by: naglis <[email protected]>
(cherry picked from commit dfc1b17) Co-authored-by: naglis <[email protected]>
(cherry picked from commit dfc1b17) Co-authored-by: naglis <[email protected]>
Still about Adapter and converter recipes Converters However the just above and symmetric corresponding Adapters named Maybe this is correct since they were executed without reported error in the reported naglis test. But it looks inconsistent and adding to confusion, the `point' example, just a few lines above in the documentation use bytes for the Converter and for the Adapter; def adapt_point(point):
return f"{point.x};{point.y}".encode("utf-8")
def convert_point(s):
x, y = list(map(float, s.split(b";")))
return Point(x, y) Thank you for the great product and documentation. |
Yeah, it is slightly confusing that we're storing strings when adapting and decoding bytes when converting, but the docs explicitly say (visually highlighted as a "note", IIRC) that SQLite values are always passed to converters as Now to the "point example"; thanks for pointing out that inconsistency. It's not a bug (the doctests would have caught that), but it is definitely inconsistent with the previous "point example"2 (yes, there are two) and inconsistent with the prose. I'll change fix this with a docs update PR. Thanks for the report, but in the future, please create a new issue instead of reusing a (related) old issue :) Footnotes |
The date/datetime SQLite converters in the Adapter and converter recipes produce
TypeError
s as they seem to expect the value passed to bestr
, however as noted in the documentation, the converters are always passed abytes
object. In theconvert_timestamp
case, a cast toint
(IIUC notfloat
, asint
is used in theadapt_datetime_epoch
adapter recipe) is missing.Below is an example based on the recipe to demonstrate the errors.
Output:
The text was updated successfully, but these errors were encountered: