edgedb / edgedb-net

The official .NET client library for EdgeDB
https://edgedb.com
Apache License 2.0
82 stars 9 forks source link

Fix dynamic query results & add config option for temporal types #34

Closed quinchs closed 1 year ago

quinchs commented 1 year ago

Summary

With 1.0.5 came the addition of new temporal types that reflect EdgeDB's temporals and precision, as well as a refactor to the internal code that is responsible for turning the binary representation of types into .NET types. There is an issue when no type information is passed to the QueryX method, the codecs couldn't figure out what type to deserialize as and would cause exceptions when trying to deserialize.

This PR adds a fix for passing object or dynamic into query methods, which correctly deserializes the data following the type descriptors returned by EdgeDB.

For complex codecs (codecs that can deserialize a binary representation into multiple different types), they will prefer the default type (usually a model type in EdgeDB.DataTypes.*) unless otherwise specified. A new config option PreferSystemTemporalTypes was added to change whether .NETs built-in temporal types will be used with dynamic query results, with this set to false (the default value), the EdgeDB.DataTypes.* temporal types will be used.

Codecs are a globally shared resource between all clients, to add a config option to change their behavior a new parameter was added to both Serialize and Deserialize called CodecContext. This is supplied by the calling client and contains all the relative information that can influence a codecs decision of how to encode/decode types.