Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AhmedLSayed9 opened this issue Jan 27, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@AhmedLSayed9
Copy link
Contributor

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 AhmedLSayed9 added the enhancement New feature or request label Jan 27, 2025
@simolus3
Copy link
Owner

A PR to change this behavior would be welcome, but this is not a priority for me. generateInsertable is meant for the case where you need some customization for a row class that roughly matches the structure drift expects. When that's not the case, you can always implement toColumns yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants