apply method
Returns the SQL string and the mapped parameters for this command.
Implementation
@override
(String, Map<String, Object?>) apply(P? p) {
_validateIdentifier(table, context: 'table');
for (final key in primaryKeys) {
_validateIdentifier(key, context: 'primary key');
}
final rawMap = _resolveParams<P>(params, p);
final finalMap = <String, Object?>{};
final where = <String>[];
for (final key in rawMap.keys) {
_validateIdentifier(key, context: 'column');
if (primaryKeys.contains(key)) {
where.add('$key = @$key');
finalMap[key] = rawMap[key];
}
}
if (where.isEmpty) {
throw ArgumentError('DeleteCommand requires at least one primary key.');
}
final sql = 'DELETE FROM $table WHERE ${where.join(' AND ')}';
return (sql, finalMap);
}