select method

FullIdWithValue? select(
  1. SqlId id
)

Returns a FullId key and a JSON Object value for the SQL id.

This method retrieves the key-value pair from the mapping table using the specified SQL id. The returned key is always of the FullId type, while the id parameter can be any of the SqlId subclasses (i.e., if id is KeyId or RowId, it is upgraded to FullId pointing to the same row and returned within FullIdWithValue). If no row with the SQL id is found, null is returned.

Implementation

FullIdWithValue? select(SqlId id) {
  checkActive();
  ResultSet result;
  if (id.hasRowId)
    result = _selectByRowId!.select([id.rowid]);
  else
    result = _selectByKeyId!.select(<Object>[id.keyid!]);
  int length = result.length;
  checkState(length == 0 || length == 1);
  return length == 0
      ? null
      : (
          id: FullId(
            id.hasRowId ? id.rowid : result.first.columnAt(0) as int,
            !id.hasRowId ? id.keyid! : result.first.columnAt(0) as Object,
          ),
          value: jsonDecode(result.first.columnAt(1) as String) as Object,
        );
}