Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Simsen3142 opened this issue Nov 24, 2023 · 1 comment

Comments

@Simsen3142
Copy link

Simsen3142 commented Nov 24, 2023

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}
});
@Simsen3142 Simsen3142 changed the title Calling MockDatabaseReference.update with null values adds null values to database instead deleting it Calling MockDatabaseReference.update with null values adds null values to database instead of deleting the entry Nov 24, 2023
@sitatec
Copy link
Owner

sitatec commented Jul 19, 2024

Thanks for reporting this, I will work on it as soon as I get some free time. PRs are also welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants