Skip to content

Allow ignoring constructor fields in @UseRowClass #3754

@KiddoV

Description

@KiddoV

Is your feature request related to a problem? Please describe.
When using @UseRowClass, Drift expects every constructor parameter of the row class to match a table column.

This makes it difficult to use domain models that contain:

  • Relationship objects (e.g. profile, creator)
  • Computed or derived fields
  • Runtime-only fields

Even when those fields are not meant to be stored in the table, Drift reports:

Unexpected parameter <field> which has no matching column

Describe the solution you'd like
Allow @UseRowClass to explicitly ignore selected constructor fields.

Example API:

@UseRowClass(
  User,
  ignoreFields: {'profile', 'creator'},
)
class Users extends Table {}

or

class User {
  final String id;

  @DriftIgnore
  final Profile profile;
}

@UseRowClass(User)
class Users extends Table {}

This would tell Drift that these fields exist on the row class but are not backed by columns.

Why this is useful

  • Many apps use rich domain models, not flat row-only models
  • Relationships are often loaded manually via joins => Can use .copyWith() directly from the model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions