Skip to content

Calling MockDatabaseReference.update with null values adds null values to database instead of deleting the entry #16

@Simsen3142

Description

@Simsen3142

Description:
when setting a value of DatabaseReference to null using update, FirebaseDatabase removes this value from the database.
MockDatabaseReference.update inserts a null value instead

How to reproduce:

test('MockDatabaseReference removes value when updating with null', () async {
  DatabaseReference reference = MockFirebaseDatabase.instance.ref('path'); // test works with FirebaseDatabase.instance.ref('path')

  await reference.update({'x':'value'});

  var snapshot = await reference.get();
  expect(snapshot.value, {'x':'value'});

  await reference.update({'x':null}); // should remove the entry

  snapshot = await reference.get();
  expect(snapshot.value, null); // this fails, actual: {'x':null}
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions