apply method
Returns the SQL string and the mapped parameters for this command.
Implementation
@override
(String, Map<String, Object?>) apply(P? p) {
final map = _resolveParams<P>(params, p);
final cols = <String>[];
final vals = <String>[];
for (final entry in map.entries) {
// Skip plain nulls, but allow SQL(null)
if (entry.value != null || entry.value is SQL) {
cols.add(entry.key);
vals.add('@${entry.key}');
}
}
if (cols.isEmpty) {
throw ArgumentError(
'InsertCommand requires at least one non-null value.');
}
final sql =
'INSERT INTO $table (${cols.join(', ')}) VALUES (${vals.join(', ')})';
return (sql, map);
}