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 54 forks source link

Should support inherited classes #178

Open andredealmei opened 4 years ago

andredealmei commented 4 years ago

My entities share common columns:

abstract class WithUpdate {
  @Column(isNullable: true)
  DateTime updatedAt;
}

When inheriting from the above class:

class SomeEntity extends WithUpdate {
  @PrimaryKey()
  int id;
}

code generation not generate fields from abstract class;

gen code:

abstract class _SomeEntityBean implements Bean<SomeEntity> {
  final id = IntField('id');
  Map<String, Field> _fields;
  Map<String, Field> get fields => _fields ??= {
        id.name: id,
      };
  SomeEntity fromMap(Map map) {
    SomeEntity model = SomeEntity();
    model.id = adapter.parseValue(map['id']);

    return model;
  }