whereNotLike method

QueryBuilder whereNotLike(
  1. String field,
  2. String pattern, {
  3. bool caseSensitive = false,
  4. bool escape = true,
})

Adds a NOT LIKE condition to the query.

field is the column to match. pattern is the SQL pattern. caseSensitive determines if the match is case-sensitive. escape determines if special characters in the pattern are escaped.

Implementation

QueryBuilder whereNotLike(String field, String pattern,
    {bool caseSensitive = false, bool escape = true}) {
  final paramName = 'p${_paramIndex++}';
  final processedPattern = escape ? _escapeLike(pattern) : pattern;

  if (DB.driver == DBDriver.postgres) {
    final sql = caseSensitive
        ? '$field NOT LIKE :$paramName'
        : '$field NOT ILIKE :$paramName';
    _wheres.add(sql);
  } else {
    final sql = caseSensitive
        ? '$field NOT LIKE ?'
        : 'LOWER($field) NOT LIKE LOWER(?)';
    _wheres.add(sql);
  }

  _bindings[paramName] = processedPattern;
  return this;
}