insert<KeyType> method
Future<KeyType>
insert<KeyType>(
- Table<
KeyType> table, - Map<
String, Object?> values, { - ConflictAlgorithm conflictAlgorithm = ConflictAlgorithm.abort,
override
Implementation
@override
Future<KeyType> insert<KeyType>(Table<KeyType> table, Map<String, Object?> values, {ConflictAlgorithm conflictAlgorithm = ConflictAlgorithm.abort}) async {
try {
// final newKey = await _db!.insert(table.name,
// table.columns.validateMapExcept(table.columns.preprocessMap(values)),
// conflictAlgorithm: conflictAlgorithm.intoPrivate());
final insertionValues = table.columns.validateMapExcept(table.columns.preprocessMap(values));
final arguments = insertionValues.entries.toList();
final newKey = await _db!.rawQuery(
table.buildInsertStatement(columnNames: arguments.map((e) => e.key), onConflict: conflictAlgorithm),
arguments.map((e) => e.value).toList(),
);
_tableChangeController.add(table);
_insertController.add((table, values, conflictAlgorithm));
return newKey.first.values.first as KeyType;
} catch (e, stack) {
print(stack);
throw sqlliteGenericException(e);
}
}