我正在尝试运行渡槽的命令来生成数据库。
aqueduct db generate
但我总是收到此错误:
Bad state: type '_SpecialTypeMirror' is not a subtype of type 'ClassMirror' in type cast
我正在使用这样的模型: 导入'package:aqueduct / aqueduct.dart'; 导入'package:controle_rural_api / models / Farm.dart';
类用户扩展ManagedObject实现_User {}
class _User {
@primaryKey
int id;
String otherThings;
bool active;
ManagedSet<Farm> farms;
}
那是完整的错误:
*** Uncaught error
Bad state: type '_SpecialTypeMirror' is not a subtype of type 'ClassMirror' in type cast
**** Stacktrace
* #0 EntityBuilder._getTableDefinitionForType (package:aqueduct/src/db/managed/builders/entity_builder.dart:236:16)
* #1 new EntityBuilder (package:aqueduct/src/db/managed/builders/entity_builder.dart:16:31)
* #2 new DataModelBuilder.<anonymous closure> (package:aqueduct/src/db/managed/builders/data_model_builder.dart:7:42)
* #3 MappedListIterable.elementAt (dart:_internal/iterable.dart:414:29)
* #4 ListIterable.toList (dart:_internal/iterable.dart:219:19)
* #5 new DataModelBuilder (package:aqueduct/src/db/managed/builders/data_model_builder.dart:7:71)
* #6 new ManagedDataModel.fromCurrentMirrorSystem (package:aqueduct/src/db/managed/data_model.dart:46:9)
* #7 MigrationBuilderExecutable.execute (<data:application/dart>:13:557)
* <asynchronous suspension>
* #8 main (<data:application/dart>:9:35)
* <asynchronous suspension>
* #9 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:296:32)
* #10 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
****
看起来与我的代码无关,但是我无法生成代码,可以做什么?
答案 0 :(得分:1)
我发现了错误。在泛型中。
在class User extends ManagedObject implements _User{}
中我忘记了类型,所以应该像这样:class User extends ManagedObject<_User> implements _User{}