feat: codec options argument for engine initialization #325
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The original idea was to resolve #118, which wants an easy feature to have all
datetime.datetime
fields as UTC-aware values.This is definitely something very, very useful, as many people (including me) consider naive datetimes a source of problems.
The proposed solution in #118 is more field-specific, but considering the issue title and the fact that most people either want timezone awareness or not (everywhere), I feel like this is the best way of getting there.
The solution here tries to:
CodecOptions
object, we are able to not only define that timezone-aware datetimes is what we want, but also other conversion stuff that some people may find useful.I must say that I believe that the solution could be cleaner if the
AIOEngine
andSyncEngine
classes were not obfuscating theself.database
object generation. I was thinking of allowing an input of a fulldatabase
object, but technically it stops making sense to input aclient
, so I had to drop the idea, as having bothclient
anddatabase
as input arguments stops making sense (thedatabase
contains a reference to the client). It would be dirtier, and a possible misuse could happen.So if there are plans for breaking the API at a certain point, it should be considered to change the initialization of these engines, extracting the
database
object generation out of theBaseEngine
subclasses, to facilitate custom configurations.Close #118