Jaguar-dart / jaguar_orm

Source-generated ORM with relations (one-to-one, one-to-many, many-to-many), preloading, cascading, polymorphic relations, etc
https://jaguar-dart.github.io
BSD 3-Clause "New" or "Revised" License
217 stars 52 forks source link

Unknown column type does not crash build #127

Closed JamesMcIntosh closed 5 years ago

JamesMcIntosh commented 5 years ago

When generating a column which is an unknown data type an error should be thrown.

When you run flutter pub run build_runner build it says that it succeeds with 1 less actions than expected. All that is shown in the console is a warning in the logs which doesn't indicate that anything went wrong.

[INFO] Running build...
[WARNING] jaguar_orm_gen:jaguar_orm_gen on lib/test/NullableClass.dart:
Generating bean for NullableClass ...
[INFO] Running build completed, took 2.2s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 47ms

[INFO] Succeeded after 2.2s with 1 outputs (1 actions)

The error is written as a comment into the jorm.dart file with a stack trace.

Field line1 has exception: Exception: Field type not recognised: Optional!
#0      Field.vType (package:jaguar_orm_gen/src/model/model.dart:21:7)
#1      Writer._generate (package:jaguar_orm_gen/src/writer/writer.dart:19:43)
#2      new Writer (package:jaguar_orm_gen/src/writer/writer.dart:11:5)
#3      BeanGenerator.generateForAnnotatedElement (package:jaguar_orm_gen/src/hook/hook.dart:41:26)
<asynchronous suspension>
#4      GeneratorForAnnotation.generate (package:source_gen/src/generator_for_annotation.dart:47:28)
<asynchronous suspension>
#5      _generate (package:source_gen/src/builder.dart:254:35)
<asynchronous suspension>
#6      _Builder._generateForLibrary (package:source_gen/src/builder.dart:72:15)
<asynchronous suspension>
#7      _Builder.build (package:source_gen/src/builder.dart:66:11)
<asynchronous suspension>
#8      runBuilder.buildForInput (package:build/src/generate/run_builder.dart:45:21)
<asynchronous suspension>
#9      MappedListIterable.elementAt (dart:_internal/iterable.dart:414:29)
#10     ListIterator.moveNext (dart:_internal/iterable.dart:343:26)

Example

import 'package:optional/optional.dart';

class NullableClass extends Equatable {
  @Column(isNullable: true)
  Optional<String> nullableValue;

  NullableClass({this.nullableValue}) : super([nullableValue]);

}
tejainece commented 5 years ago

Will fix this.

tejainece commented 5 years ago

This is fixed in 4.x.x version.

Please file a new issue for Optional.