makeWhere method

String makeWhere(
  1. String where,
  2. String x,
  3. List<String> primary
)

This method is used to construct a WHERE clause for SQL operations.

It takes a current WHERE clause, a field name, and a list of primary keys as parameters. It adds a condition for the field to the WHERE clause. If the field is the last primary key, it simply adds the condition to the WHERE clause. If the field is not the last primary key, it adds the condition followed by 'AND' to the WHERE clause.

Parameters: where (String): The current WHERE clause. x (String): The field name to add to the WHERE clause. primary (List

Returns: String: The updated WHERE clause.

Implementation

String makeWhere(String where, String x, List<String> primary) {
  var whereToAdd = '$where $x = ?';
  if (x == primary.last) {
    where += whereToAdd;
  } else {
    where = "$where $whereToAdd AND ";
  }
  return where;
}