floor
floor copied to clipboard
Duplicate fields are added when an entity `implements` a class
I am having an issue with generating an entity that overrides properties from an implemented or extended class.
I might be missing something as I've only spent an hour with the library but from what I can see the following is true:
@Entity()
class User extends IdEntity implements NamedEntity {
@override
@PrimaryKey()
int id;
@override
String name;
}
class IdEntity {
int id;
}
class NamedEntity {
String name;
}
Produces the following in the database.g.dart
await database.execute('CREATE TABLE IF NOT EXISTS `User` (`id` INTEGER, `name` TEXT, `id` INTEGER, `name` TEXT, PRIMARY KEY (`id`))');
Notice the duplicate properties: `id` INTEGER, `name` TEXT, `id` INTEGER, `name` TEXT`
It looks like we could de-duplicate fields in? https://github.com/vitusortner/floor/blob/2a762675b0f543af296ddee33b7ef66e1ae939ff/floor_generator/lib/processor/queryable_processor.dart#L36-L52
I can confirm that you can work around this issue by applying @Ignore
to the base class. As follows:
class IdEntity {
@ignore
int id;
}
class NamedEntity {
@ignore
String name;
}
If this is the intended outcome of such a structure may be a simple update to the docs would help other newbies like me?
seems to be similar to #515
could anyone tell me how to fix it if I can not add @ignore ?
Because the base class is in an library and the library is also used by a dart backend project.
got the same problem