Open BenVercammen opened 1 year ago
I can see use cases for custom serialization. Good feature to have.
A couple of points to note:
melos
, though I've noticed that previous commits don't follow those conventions, so you may want to reword the commit messages for consistencypubspec.yaml
file, as this is required when using melos:3.0
(don't think melos:2.x
cares...)dependency_overrides
to get the tests working on my local machineenum_test.dart
) as I wanted to validate my issue. Not sure if that's the best place to do so though, so you may want to look into that one as well...
Consider the following classes:
Currently, the generated
HasCarQuery
class will have aparseRow
method that looks something like this:The generated
HasCarSerializer
will (de)serialize using the definedcolorToCode(model.color)
andcodeToColor(map['color'])
methods. This results in the value being persisted in the databse as aString
, but since the enum handler just assumes that the indeces are being persisted, it will try to read that value as anint
, resulting in a type cast exception.Therefore, I'd like to propose that the
OrmGenerator
will also take the following@SerializableField
properties into account:serializer
deserializer
serializesTo
Any thoughts on this? I'll submit a PR as soon as possible...