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.
Currently the
None
data type is not being serialized properly in thecbor
protocol and this pull request fixes this.Python's
cbor
library serializesNone
types automatically before they have a chance of reaching our encoder. While we are looking into ways to override default serialization methods, we have our own data type that denotes aNone
type which can be shown below:It must be noted that the field that had a
None
is not returned as a field at all. Using a.get()
function will give the same effect as if the field is there but it is aNone
. Using aoutcome["age"]
will throw an error. We can also see how it works when the field is not None with the following code:Here we can see that the age is returned because it is not
None
. There is a slight performance cost for thisNone
safety as the client needs to recursively go through the data passed into the client replacingNone
withNoneType
. If you do not want this performance cost, you can disable the check but you have to ensure that allNone
types you pass into the client are replaced yourself. You can us aNoneType
via the following code:Here we set the environment variable
SURREALDB_BYPASS_CHECKS
to"true"
.Tests
The code in the documentation of this pull request is now in the testing suite.