WherePhrase constructor

const WherePhrase(
  1. List<WhereCondition> conditions, {
  2. bool? isRequired,
})

A collection of conditions that are evaluated together.

If mixing required:true required:false is necessary, use separate WherePhrases. WherePhrases can be mixed with Where.

Invalid:

WherePhrase([
  Where.exact('myField', true),
  Or('myOtherField').isExactly(0),
])

Valid:

WherePhrase([
  Where.exact('myField', true),
  WherePhrase([
    Or('myOtherField').isExactly(0),
    Or('myOtherField').isExactly(1),
  )]
])

Implementation

// Why isn't WherePhrase a Where?
// The type hinting of distinct classes leads to a positive dev experience. When you type Where( you get a hint that the first arg is a column and the second arg is a value. When you type WherePhrase(, you get a hint that the first arg is a List.
//
// This also avoids putting too much logic into a single class by splitting it between two that should functionally be different. Determining if we're dealing with a Where or a WherePhrase also makes life easy on the translator.
//
// `required` also operates slightly differently for both. In where, it's the column. In WherePhrase, it's the whole chunk.
const WherePhrase(
  this.conditions, {
  bool? isRequired,
}) : isRequired = isRequired ?? false;