jaguar_orm icon indicating copy to clipboard operation
jaguar_orm copied to clipboard

Feature request - support Optional data type

Open JamesMcIntosh opened this issue 5 years ago • 3 comments

When creating the model it would be great to have nullable columns handled with the Optional so nullability becomes explicit and null checks can be removed from the code.

import 'package:optional/optional.dart';

class NullableClass extends Equatable {
  @Column(isNullable: true)
  Optional<String> nullableValue;
  
  NullableClass({this.nullableValue}) : super([nullableValue]);

}

Current behaviour is an Exception which is logged in the generate .jorm.dart files, see issue #127

JamesMcIntosh avatar May 21 '19 04:05 JamesMcIntosh

Another area which Optional could be introduced is in the generated bean's find

Future<Optional<?>> find(int id)

Future<?> get(int id)

JamesMcIntosh avatar May 22 '19 01:05 JamesMcIntosh

Will look into this.

tejainece avatar May 23 '19 08:05 tejainece

dart will (soon?) have nullable field so it will be better to wait for it and use it once it's there instead of playing around and add an Optional class that will complexify the core code

jaumard avatar Oct 04 '19 14:10 jaumard