insertOrReplaceWith method
Statement
insertOrReplaceWith(
- QualifiedTablename table,
- List<
String> columns, - List<
Object?> values, - List<
String> conflictCols, - List<
String> updateCols, - List<
Object?> updateVals,
override
Insert a row into a table.
If it already exists we update the provided columns updateCols
with the provided values updateVals
Implementation
@override
Statement insertOrReplaceWith(
QualifiedTablename table,
List<String> columns,
List<Object?> values,
List<String> conflictCols,
List<String> updateCols,
List<Object?> updateVals,
) {
final insertOrReplaceRes = insertOrReplace(
table,
columns,
values,
conflictCols,
updateCols,
);
return Statement(
'${insertOrReplaceRes.sql} ON CONFLICT DO UPDATE SET ${updateCols.map((col) => '$col = ?').join(', ')}',
[...insertOrReplaceRes.args!, ...updateVals],
);
}