buildInsertStatement method
String
buildInsertStatement({
- Iterable<
String> ? columnNames, - ConflictAlgorithm onConflict = ConflictAlgorithm.abort,
This builds an insert statement It takes in the values as a list to assert the order. If not provided order cannot be guaranteed
Implementation
String buildInsertStatement({Iterable<String>? columnNames, ConflictAlgorithm onConflict = ConflictAlgorithm.abort}) {
final buffer = StringBuffer('INSERT OR ${onConflict.name} INTO $tableName\n');
buffer.write("(");
buffer.write((columnNames ?? columns.map((e) => e.name)).join(", "));
buffer.writeln(")");
buffer.write("VALUES (");
buffer.write((columnNames?.map((e) => "?") ?? columns.map((e) => "?")).join(", "));
buffer.writeln(")");
buffer.write("RETURNING ${primaryKey.toSqlList()}");
return buffer.toString();
}