VirtualColumn constructor

VirtualColumn({
  1. int version = schemeElementInitialVersion,
  2. required String name,
  3. required KindList kinds,
  4. required Sql sql,
})

Creates a description of a virtual column using the given parameters.

The value of the virtual column is equal to the result of the sql expression. If kinds is empty, this expression is evaluated for every row; otherwise, it is evaluated only for rows whose kinds are included in the kinds property, while rows of other kinds will have NULL as the value of the virtual column.

It is expected that every kind is a String or a finite num. In no-kinds mode, when Scheme.kindPath is set to unsetKindPath, the kinds property must be empty.

The name argument must not match any of the following reserved names: columnRowId, columnKeyId, columnValue, or columnKind.

See also: SchemeElement.new.

Implementation

VirtualColumn({
  super.version = schemeElementInitialVersion,
  required super.name,
  required this.kinds,
  required this.sql,
}) {
  checkState(
    !_reserved.contains(lcName),
    message: () => "VirtualColumn: name `$name` is reserved",
  );
  checkState(
    kinds.every(isSqlValue),
    message: () =>
        "VirtualColumn[name=$name]: kinds must be strings or finite nums",
  );
  checkState(
    HashSet<Kind>.of(kinds).length == kinds.length,
    message: "VirtualColumn[name=$name]: kinds must not have duplicates",
  );
}