-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Description
I have this data class with a custom upsert methode:
@MappableClass()
class TrainingRecord {
static const tableName = "training_record";
@override
final String id;
final DateTime? end;
TrainingRecord({
required this.id,
this.end,
});
Future<void> upsert() async {
await db.execute('''
INSERT OR REPLACE INTO $tableName (id, end)
VALUES (?, ?)
''', [
id,
end?.toIso8601String(),
]);
}
If upsert
is invoked then in my PowerSyncSupabaseConnector
the map op.opData
doesn't contains null values.
@override
Future<void> uploadData(PowerSyncDatabase database) async {
final transaction = await database.getNextCrudTransaction();
if (transaction == null) {
return;
}
final rest = Supabase.instance.client.rest;
CrudEntry? lastOp;
try {
for (var op in transaction.crud) {
lastOp = op;
final table = rest.from(op.table);
if (op.op == UpdateType.put) {
**var data = Map<String, dynamic>.of(op.opData!); // The 'end' field is missing from op.opData when its value is null“**
As a result i have to insert them manually in the map e.g:
if (op.table == TrainingRecord.tableName && !data.containsKey("end")) {
data['end'] = null;
}
Otherwise they are ignore by
data['id'] = op.id;
await table.upsert(data);
I'm unsure if this is a bug or a feature 🤔
Thanks in advance
Metadata
Metadata
Assignees
Labels
No labels