PartialIndex constructor

PartialIndex({
  1. int version = schemeElementInitialVersion,
  2. required String name,
  3. required IndexColumns columns,
})

Creates a description for a partial index of the given columns.

A row is excluded from the index if at least one of the specified columns within that row is NULL.

The name argument must not match the reserved names tableMapping, tableScheme, and columnKind, nor must it, within the same database, match the name of any partial index, search index, or FTS5 shadow table. Also, the name must not start with the reserved prefix sqlite_.

See also: SchemeElement.new.

Implementation

PartialIndex({
  super.version = schemeElementInitialVersion,
  required super.name,
  required this.columns,
}) {
  checkState(
    columns.isNotEmpty,
    message: () =>
        "PartialIndex.new[name=$name] requires at least one column",
  );
  checkState(
    !lcName.startsWith("sqlite_"),
    message: () =>
        "PartialIndex.new[name=$name]: "
        "name starts with the reserved prefix `sqlite_`",
  );
  if (columns.map((var e) => e.lcName) case var c
      when HashSet<String>.from(c).length != c.length)
    throw StateError("PartialIndex.new: coinciding column names ($c)");
}