firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.62k stars 1.48k forks source link

Async getData() returns the value of parent node instead of the child node. #12965

Open kahaYu opened 5 months ago

kahaYu commented 5 months ago

Description

Hello!

When I call the async getData() method, it returns the snapshot of the parent, not the actual child.

Reproducing the issue

Create User node and two nodes inside of it: id, name.

Call: let userId = try! await Database.database().reference().child("User").child("id").getData().value

It returns 2 key-value pairs id="testId", name="testName". But not the id only.

Firebase SDK Version

10.17.0

Xcode Version

15.1

Installation Method

Swift Package Manager

Firebase Product(s)

Database

Targeted Platforms

iOS

Relevant Log Output

No logs.

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
```json Replace this line with the contents of your Package.resolved. ```

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
```yml Replace this line with the contents of your Podfile.lock! ```
google-oss-bot commented 5 months ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

mortenbekditlevsen commented 5 months ago

This appears to be the same issue as #12168 and #12225. I have an attempt at a fix here: https://github.com/firebase/firebase-ios-sdk/pull/12169 But in a comment on #12225 back in February, 2024 @paulb777 mentions that the issue is more involved than what my fix is solving.

We are encountering hard-to-discover bugs related to this issue, and I would love to help fixing it.

@paulb777 Would it at all be possible for you to share your investigations about the extent of this issue, so that myself or others might be able to help fixing the issue?

kahaYu commented 5 months ago

Thanks for the reply @mortenbekditlevsen Ok, will wait for the fix, until then will get the whole bundle of data and locally grab the needed fields. Which results in more spendings on Firebase though haha

pangia commented 3 months ago

Any update on this? This issue is causing a lot of data to be downloaded to the client.. and that cost $$$