asWhereClausule method

String asWhereClausule({
  1. bool nullAsBlank = false,
  2. dynamic quoteChar,
  3. String dataBaseProvider = "",
  4. bool and = true,
})

Generates a WHERE clause for the given map of column names and values.

The nullAsBlank parameter determines whether null values should be treated as blank strings. The quoteChar parameter specifies the character used for quoting identifiers. The dataBaseProvider parameter specifies the database provider. The and parameter determines whether to use "AND" or "OR" in the WHERE clause.

Returns the generated WHERE clause as a string.

Implementation

String asWhereClausule({
  bool nullAsBlank = false,
  dynamic quoteChar,
  String dataBaseProvider = "",
  bool and = true,
}) {
  return entries
      .map((e) => "${SqlUtil.wrap(e.key, quoteChar, dataBaseProvider)} ${e.value == null && nullAsBlank == false ? "is" : "="} ${SqlUtil.value(e.value, nullAsBlank)}")
      .join(' ${and ? "AND" : "OR"} ');
}