Skip to content

Commit

Permalink
Merge pull request #366 from atharvapalaskar/main
Browse files Browse the repository at this point in the history
fixes: #365;
  • Loading branch information
Seven Du authored May 28, 2024
2 parents 60d1af7 + d7cde03 commit 9dab299
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bin/src/generate_output.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extension on Generator {
Method generateToJsonMethod(dmmf.OutputType output) {
Expression generateValueExpression(Expression value, dmmf.OutputField field,
[bool nullable = true]) {

if ((field.outputType.location == dmmf.TypeLocation.scalar &&
field.outputType.type == 'Json') ||
field.outputType.location == dmmf.TypeLocation.outputObjectTypes) {
Expand All @@ -52,6 +53,18 @@ extension on Generator {

return call([]);
}
else if(field.outputType.location == dmmf.TypeLocation.scalar &&
field.outputType.type == 'DateTime') {
final call = nullable
? value.nullSafeProperty('toIso8601String')
: value.property('toIso8601String');
return call([]);
}
else if(field.outputType.location == dmmf.TypeLocation.enumTypes) {
return nullable
? value.nullSafeProperty('name')
: value.property('name');
}

return value;
}
Expand Down

0 comments on commit 9dab299

Please sign in to comment.