getSqliteRow function
Map<String, Object?> ?
getSqliteRow(
- SqliteDatabase db,
- String table,
- SqliteRowLookup lookup,
- String key,
Looks a row up by primary key or rowid (omp's getRowByKey /
getRowByRowId). Returns null when no row matches.
Implementation
Map<String, Object?>? getSqliteRow(
SqliteDatabase db,
String table,
SqliteRowLookup lookup,
String key,
) {
_getTableMasterRow(db, table);
final result = switch (lookup) {
SqlitePkLookup(:final column, :final type) => db.select(
'SELECT * FROM ${_quoteSqliteIdentifier(table)} WHERE '
'${_quoteSqliteIdentifier(column)} = ? LIMIT 1',
parameters: [_coerceLookupValue(key, type)],
),
SqliteRowidLookup() => db.select(
'SELECT * FROM ${_quoteSqliteIdentifier(table)} WHERE rowid = ? LIMIT 1',
parameters: [_coerceIntegerKey(key, 'SQLite ROWID')],
),
};
return result.rows.isEmpty ? null : result.rows.first;
}