flutterfire
flutterfire copied to clipboard
🐛 [ODM] generated orderBy methods do not support aliases
Bug report
Describe the bug
When the name
is defined in the JsonKey for a field that has a different name on the class and in the field in cloud firestore the generated orderBy methods return no results.
Steps to reproduce
Steps to reproduce the behavior:
Define a model with a aliased name
class MyModel{
MyModel({
this.name,
this.displayOrder,
})
@JsonKey()
string name;
@JsonKey(name: 'display_order')
int displayOrder;
}
Notice that in the generated orderByDisplayOrder
method on the MyModelQuery
class the query line is var query = reference.orderBy('displayOrder', descending: false);
This causes zero documents to be returned when using the ordering method.
Expected behavior
It is expected that the the query is var query = reference.orderBy('display_order', descending: false);
, using the name
from the JsonKey
annoatation.
Renaming properties is not supported at the moment.
This should have been closed before. Renaming is supported now, although it requires enabling a specific json_serializable flag (createFieldMap)
So closing