update method

  1. @protected
bool update(
  1. SqlId id,
  2. Object value
)

Implementation

@protected
bool update(SqlId id, Object value) {
  Kind? kind;
  int rowid;
  if (id.hasRowId) {
    var rows = _updateByRowId!.select([jsonEncode(value), id.rowid]);
    if (!updated() || rows.length != 1) ////
      return false;
    kind = rows.first.columnAt(0) as Kind?;
    rowid = id.rowid;
  } else {
    var rows = _updateByKeyId!.select(<Object>[jsonEncode(value), id.keyid!]);
    if (!updated() || rows.length != 1) ////
      return false;
    kind = rows.first.columnAt(0) as Kind?;
    rowid = rows.first.columnAt(1) as int;
  }
  if (scheme.getSearchIndexesUpdater(kind) case var updaters?)
    for (var entry in updaters.toIterable()) {
      SearchRow searchRow = entry.rowGetter(value);
      entry.indexUpdater.update.executeWith(
        StatementParameters.named({
          ...searchRowToParameters(searchRow),
          ":$columnRowId": rowid,
        }),
      );
      if (!updated())
        log.severe(
          "SQLite.update: failed for rowid $rowid, kind \"$kind\","
          " search index \"${entry.indexUpdater.index.name}\"",
        );
    }
  return true;
}