-
I would like the behavior prior to this change #1307 I think this might be possible by registering an adapter to handle large dates. However, how would the comparison operator work in this situation (does anyone have sample code). I have a postgres db where I have user input dates which often have some crazy values and I'd like to enforce a max of 9999-12-31 when moving over to python instead of failing on fetch |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
What do you need how comparison operator work? If you compare in postgres, comparison works according to postgres rules. If you compare in Python, comparison works according to Python rules. You can register your own adapter and customize the treatment of overflowing dates any way you wish; comparison will depend on where you do it and is unrelated. |
Beta Was this translation helpful? Give feedback.
-
@dvarrazzo do you have code pointer to an adapter that compares in postgres? from the few adapter examples i was looking at, i assume i need to parse strings in python to infer if year is too large. was mostly wondering if there was a better way / more obvious way to do this |
Beta Was this translation helpful? Give feedback.
If you can make a comparison in postgres you may as well sanitize the value returning them within an expected range:
If you want to use a custom adapter, you can make one that returns
datetime.max
in case of overflow. The example is for thetimestamptz
; you can do something similar fortimestamp
anddate
types.