whereInIfNotEmpty<V> method

S whereInIfNotEmpty<V>(
  1. Iterable<V> values,
  2. MssqlCondition predicate(
    1. TFields fields,
    2. List<V> values
    )
)

Adds predicate only when values is not empty.

An empty IN is invalid SQL and must not silently become "match nothing" or "match everything". Skipping the callback is the intended reading of an empty filter.

Implementation

S whereInIfNotEmpty<V>(
  Iterable<V> values,
  MssqlCondition Function(TFields fields, List<V> values) predicate,
) {
  final list = List<V>.of(values);
  if (list.isEmpty) return _self;
  return where((f) => predicate(f, list));
}