resolvedPrimaryKey property

Set<TableColumn<Object>> get resolvedPrimaryKey

The resolved primary key of this table.

This is the Table.primaryKey when set on the table, but can also be a column with a primary key constraint on it.

Implementation

Set<TableColumn> get resolvedPrimaryKey {
  if (primaryKey case final fromTableConstraint?) {
    return fromTableConstraint.cast();
  }

  return <TableColumn>{
    for (final column in columns)
      if (column.constraints.any((e) => e is ColumnPrimaryKeyConstraint))
        column,
  };
}