MssqlOutputClause constructor

MssqlOutputClause(
  1. Iterable<MssqlOutputColumn> columns, {
  2. MssqlOutputTarget? into,
})

Implementation

MssqlOutputClause(Iterable<MssqlOutputColumn> columns, {this.into})
  : columns = List<MssqlOutputColumn>.unmodifiable(columns) {
  if (this.columns.isEmpty) {
    throw ArgumentError.value(
      columns,
      'columns',
      'An OUTPUT clause needs at least one column.',
    );
  }
  final target = into;
  if (target == null) return;
  for (final column in this.columns) {
    if (column.as == null) continue;
    throw ArgumentError.value(
      columns,
      'columns',
      'OUTPUT … INTO takes no column aliases; "${column.as}" would have '
          'nowhere to go. The target\'s column list decides the order.',
    );
  }
  if (target.columns.isNotEmpty &&
      target.columns.length != this.columns.length) {
    throw ArgumentError.value(
      into,
      'into',
      'The target names ${target.columns.length} columns but the clause '
          'outputs ${this.columns.length}.',
    );
  }
}