drift icon indicating copy to clipboard operation
drift copied to clipboard

Allow the generated Insertable to work with manager references around custom row classes

Open AhmedLSayed9 opened this issue 10 months ago • 3 comments

If we try to build the generated code for the following tables:

class AnotherTable extends Table {
  IntColumn get id => integer().autoIncrement()();
}

@UseRowClass(Item, generateInsertable: true)
class Items extends Table {
  IntColumn get id => integer().autoIncrement()();
  IntColumn get anotherTable => integer().references(AnotherTable, #id)();
}

class Item {
  Item({required this.id});

  final int id;
}

It will throw a warning: This class used as a custom row class for which an insertable is generated. This means that it must define getters for all columns, but some are missing: anotherTable

It would be great if we can support generating toColumns which requires passing anotherTable to make that work.

So, user will be able to use toInsertable as following:

item.toInsertable(anotherTable: someId)

AhmedLSayed9 avatar Jan 27 '25 21:01 AhmedLSayed9