Async getData() returns the value of parent node instead of the child node.
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.
- User -- id : testId -- name: testName
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
Replace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
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?
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
Any update on this? This issue is causing a lot of data to be downloaded to the client.. and that cost $$$
Im having the same issue, came from here: https://stackoverflow.com/questions/72439469/calling-getdata-on-firebase-databasereference-returns-the-data-for-the-parent-re
UPDATE: In case someones need it, I figure a work around:
https://stackoverflow.com/a/79178267/4017501
I don't think this is a solution at SDK level because "objective C", however the same pattern must have a version in that language, right?
Im having the same issue, came from here: https://stackoverflow.com/questions/72439469/calling-getdata-on-firebase-databasereference-returns-the-data-for-the-parent-re
UPDATE: In case someones need it, I figure a work around:
https://stackoverflow.com/a/79178267/4017501
I don't think this is a solution at SDK level because "objective C", however the same pattern must have a version in that language, right?
Thanks for the reply @cutiko, Do you have any idea if there is a way to implement this workaround in a Flutter framework? Thanks in advance :)
Will this ever be fixed? This is a huge issue.
Wow, I've been trying to report this on StackOverflow and the Firebase forums for years and getting shouted down by one particularly dismissive employee. Glad to see that it's finally been publicly acknowledged as a real issue.
It's very real. I've tried fixing it myself here:
https://github.com/firebase/firebase-ios-sdk/pull/12169
I must admit that I forgot why the PR was not accepted, but I think the reason I got was that the issue was bigger than what my PR attempts to fix.
Would love to hear more details about that, because I would very much like to help fix the issue.
Right. It's an acknowledged issue that requires a more complicated fix.
If you haven't yet, please thumbs-up the issue up top to help with prioritization.
Right. It's an acknowledged issue that requires a more complicated fix.
If you haven't yet, please thumbs-up the issue up top to help with prioritization.
you got it, friend 🫡