-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Labels
type/bugThe PR fixed a bug or issue reported a bugThe PR fixed a bug or issue reported a bug
Description
It seems that the schema support in the client 2.3.0 on python 3.7 is not working with subrecords.
This example produces an error when encoding ():
"TypeError: Object of type MySubRecord is not JSON serializable"
import json
from pulsar.schema import Record, String, JsonSchema
def test_complex():
class MySubRecord(Record):
a = String()
class Example(Record):
sub = MySubRecord() # Test with instance
r = Example(sub = MySubRecord( a = 'string' ))
assert r.sub.a == 'string'
s = JsonSchema(Example)
# Produces "TypeError: Object of type MySubRecord is not JSON serializable"
data = s.encode(r)
assert json.loads(data)['sub']['a'] == 'string'Is there something I missed in the implementation? I tested with AvroSchema with no success.
I expected the client to use a custom encoder that would have encoded the subrecord.
What do you think?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type/bugThe PR fixed a bug or issue reported a bugThe PR fixed a bug or issue reported a bug