Hi.
I'm trying to create some BaseDao, in order to reuse some basic database operations:
class BaseDao<T extends DataClass> extends DatabaseAccessor<MyDatabase> {
final Table _table;
BaseDao(MyDatabase db, this._table) : super(db);
Future insertOne(Insertable<T> value) => into(_table).insert(value);
Future<List<T>> selectAll() => select(_table).get();
Future<bool> updateOne(Insertable<T> value) => update(_table).replace(value);
Future deleteOne(Insertable<T> value) => delete(_table).delete(value);
}
abstract class AbstractProductDao extends BaseDao<ProductTableData> {
AbstractProductDao(MyDatabase db) : super(db, db.productTable);
}
part 'product_dao.g.dart';
@UseDao(tables: [ProductTable])
class ProductDao extends AbstractProductDao
with _$ProductDaoMixin {
ProductDao(MyDatabase db) : super(db);
}
[SEVERE] moor_generator:moor_generator on lib/db/daos/product_dao.dart:
Error running MoorGenerator
NoSuchMethodError: The getter 'includes' was called on null.
Receiver: null
Tried calling: includes
[SEVERE] moor_generator:moor_generator on lib/db/daos/product_dao.dart:
Error running DaoGenerator
NoSuchMethodError: The getter 'includes' was called on null.
Receiver: null
Tried calling: includes
[INFO] Running build completed, took 13.6s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 176ms
[SEVERE] Failed after 13.8s
pub finished with exit code 1
Unfortunately this doesn't work. Any idea how to achieve such a inheritance hierachy?
I like the idea of supporting abstract daos, I'll check what needs to be done in the generator to support this.
Btw, you can probably get better type safety like this:
```dart
class BaseDao
final TableInfo
// ...
abstract class AbstractProductDao extends BaseDao
````
But first it needs to be supported in the generator, of course.
This will be supported in the next moor update.
Most helpful comment
I like the idea of supporting abstract daos, I'll check what needs to be done in the generator to support this.
Btw, you can probably get better type safety like this: extends DatabaseAccessor { _table; {
```dart
class BaseDao
final TableInfo
// ...
abstract class AbstractProductDao extends BaseDao
````
But first it needs to be supported in the generator, of course.