You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a few alternative Python libraries for handling datetimes. For example, Delorean and Arrow make it much easier to work with timezone-aware objects. Unfortunately, these two don't subclass from datetime (for good reasons), so the AST doesn't know how to handle them. It'd be convenient if the RethinkDB driver could handle these without the client having to explicitly cast to datetime prior to persisting.
One problem with this is what to return -- we only have one ReQL time type, so if someone inserted a time using one of these other types and then retrieved the row they'd get back the Python datetime type instead. Maybe we could solve that by having an optarg to run that specifies which Python type to give back for ReQL types?
I hadn't thought of how to specify the return type, but perhaps the most general solution would allow the user to define an encoder and a decoder to perform arbitrary mappings prior to being parsed/returned by RethinkDB (this could probably stand alone in the client code, but I think it's a common enough recipe that you may want to provide first-class support similar to the encoder/decoder options in Python's JSON module).
Alright, putting this into 2.2 and marking as a ReQL proposal since we need to discuss the API for specifying what format to return times in. (Probably we'll just extend the time_format optarg.)
I typically use moment for date manipulation, so I'd like to see this in the JS driver as well.
I think I'd prefer to override the serialization/deserialization functions for any pseudo type (similar to what @brianjpetersen suggested) rather than an optarg specific to datetimes.
There's already a time_format optarg that accepts native and raw, so it might be easiest to just extend that, but I'm not necessarily opposed to a more general system.
Activity
mlucy commentedon Jul 6, 2015
Thanks for the suggestion @brianjpetersen !
One problem with this is what to return -- we only have one ReQL time type, so if someone inserted a time using one of these other types and then retrieved the row they'd get back the Python datetime type instead. Maybe we could solve that by having an optarg to
runthat specifies which Python type to give back for ReQL types?@Tryneus, any thoughts?
brianjpetersen commentedon Jul 6, 2015
I hadn't thought of how to specify the return type, but perhaps the most general solution would allow the user to define an
encoderand adecoderto perform arbitrary mappings prior to being parsed/returned by RethinkDB (this could probably stand alone in the client code, but I think it's a common enough recipe that you may want to provide first-class support similar to the encoder/decoder options in Python's JSON module).mglukhovsky commentedon Jul 6, 2015
I think this is worthwhile -- I couldn't imagine manipulating dates and times in Python without Delorean (and Arrow looks neat!)
mlucy commentedon Jul 6, 2015
Alright, putting this into 2.2 and marking as a ReQL proposal since we need to discuss the API for specifying what format to return times in. (Probably we'll just extend the
time_formatoptarg.)deontologician commentedon Jul 6, 2015
Related to #3506
marshall007 commentedon Jul 7, 2015
I typically use
momentfor date manipulation, so I'd like to see this in the JS driver as well.I think I'd prefer to override the serialization/deserialization functions for any pseudo type (similar to what @brianjpetersen suggested) rather than an optarg specific to datetimes.
mlucy commentedon Jul 7, 2015
There's already a
time_formatoptarg that acceptsnativeandraw, so it might be easiest to just extend that, but I'm not necessarily opposed to a more general system.shastingspod commentedon Jul 7, 2015
+1
Allow alternative pseudo type handling for #4503.
Allow alternative pseudo type handling for rethinkdb#4503.