Skip to content

Map null in map to undefined for JS database #493

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

Closed
wants to merge 2 commits into from

Conversation

Daeda88
Copy link
Contributor

@Daeda88 Daeda88 commented Apr 10, 2024

No description provided.

@Daeda88
Copy link
Contributor Author

Daeda88 commented Apr 10, 2024

@nbransby re #448 (comment)
If its specific to updateChildren on JS, this should fix it.

Im not sure how JS is supposed to handle null in a map though. Like in EncodersTest.encodeDecodeGenericClass, is it supposed to be
"nullableBool": null or "nullableBool": undefined?

@Daeda88
Copy link
Contributor Author

Daeda88 commented Apr 10, 2024

I should note that if I go back to the commit before the Serialization changes where merged, I dont see anything that would do this mapping either.

@nbransby
Copy link
Member

Yes I had a look myself and couldn't see anything either. All I know is rolling back fixes it, I'll have to investigate it more

@Daeda88
Copy link
Contributor Author

Daeda88 commented Apr 10, 2024

Lets see if we can write a test that reproduces it I guess

@Daeda88
Copy link
Contributor Author

Daeda88 commented Apr 10, 2024

So far, on master. I havent been able to reproduce using:

@Test
    fun testUpdateChildren() = runTest {
        setupRealtimeData()
        val reference = database
            .reference("FirebaseRealtimeDatabaseTest")
        reference.updateChildren(mapOf("lastActivity" to null))
    }

    private suspend fun setupRealtimeData() {
        ensureDatabaseConnected()
        val firebaseDatabaseTestReference = database
            .reference("FirebaseRealtimeDatabaseTest")

        val firebaseDatabaseChildTest1 = FirebaseDatabaseChildTest("aaa")
        val firebaseDatabaseChildTest2 = FirebaseDatabaseChildTest("bbb")
        val firebaseDatabaseChildTest3 = FirebaseDatabaseChildTest("ccc")

        val values = firebaseDatabaseTestReference.child("values")
        values.child("1").setValue(firebaseDatabaseChildTest1)
        values.child("2").setValue(firebaseDatabaseChildTest2)
        values.child("3").setValue(firebaseDatabaseChildTest3)
        firebaseDatabaseTestReference.child("lastActivity").setValue(1)
    }

given

{
  "rules": {
    ".read": true,
    "FirebaseRealtimeDatabaseTest": {
      "values": {
        ".write": true
      },
      "lastActivity": {
        ".validate": "!newData.exists() || newData.isNumber()",
        ".write": true
      }
    }
  }
}

Whereas reference.updateChildren(mapOf("lastActivity" to "bla")) does fail

@Daeda88
Copy link
Contributor Author

Daeda88 commented Apr 11, 2024

I found a bug in OnDisconnect specifically, will make a patch for that once I have testing figured out

@Daeda88
Copy link
Contributor Author

Daeda88 commented Apr 11, 2024

Closing cause real fix is here #494

@Daeda88 Daeda88 closed this Apr 11, 2024
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

Successfully merging this pull request may close these issues.

2 participants