0
votes

I have this table with a set of unique keys {id, order}. The problem is that when I create a new part in a different order, it automatically replaces the entire part. If I had the part with id 1 associated with order 5, when I create a new part, which will have id 1, in order 3 for example, it deletes the part that had been associated with order number 5 to create the new one in order 3.

When I create a new part I use the insertOrReplace mode because otherwise it says that already exists a part with that constraints. Even if it doesn't.

I do something wrong? What should I do? Thanks.

@DataClassName('Part')
class Parts extends Table {
  IntColumn get id => integer()();
  TextColumn get startDate => text().withLength(min: 17, max: 17)();
  TextColumn get endDate => text().withLength(min: 0, max: 17)();
  TextColumn get observations => text()();
  IntColumn get order =>
      integer().customConstraint('NOT NULL REFERENCES orders (id)')();

  @override
  List<Set<Column>> get uniqueKeys => [
        {id, order}
      ];
}