insertOrReplace method
Statement
insertOrReplace(
- QualifiedTablename table,
- List<
String> columns, - List<
Object?> values, - List<
String> conflictCols, - List<
String> updateCols,
override
Insert a row into a table, replacing it if it already exists.
Implementation
@override
Statement insertOrReplace(
QualifiedTablename table,
List<String> columns,
List<Object?> values,
List<String> conflictCols,
List<String> updateCols,
) {
return Statement(
'''
INSERT INTO $table (${columns.map(quote).join(', ')})
VALUES (${columns.mapIndexed((i, _) => '\$${i + 1}').join(', ')})
ON CONFLICT (${conflictCols.map(quote).join(', ')}) DO UPDATE
SET ${updateCols.map((col) => '${quote(col)} = EXCLUDED.${quote(col)}').join(', ')};
''',
values,
);
}