bind method

R Function(List<Object?>) bind(
  1. List<String> labels
)

Resolves labels before reading any rows, including an empty result. Missing or duplicate required labels fail with SQL.RESULT.

Implementation

R Function(List<Object?>) bind(List<String> labels) {
  final indices = <String, int>{};
  for (final (index, label) in labels.indexed) {
    indices[label] = indices.containsKey(label) ? -1 : index;
  }
  for (final column in columns) {
    if ((indices[column.name] ?? -1) < 0) {
      throw OrmException(
        'SQL.RESULT',
        'Expected one result column named ${column.name}.',
      );
    }
  }
  return _bind(indices);
}