Open bonnybun opened 1 year ago
Thanks for the detailed report @bonnybun
I created the sample db and ran the code sample, but have been getting null
upon following steps to replicate. Did I miss something to properly replicate ?
Did you set the rules in your db @darshankawar ?
{
"rules": {
".read": "true",
".write": "true"
}
}
Yes, I have the rules properly set. I figured that the database instance reference isn't correct as mentioned in your code sample. Instead of organizations/0
and organizations/0/data
, it should be organizations/data
and organizations/data/0
. After fixing this, I was able to run and see the behavior as below:
According to my findings, tapping get
gives ["a","b","c","d","e","f","g","h"]
, but with once
, it gives only a
. Is this correct interpretation of your issue ? Because in your expected results, you mentioned that The expected value is ["a","b","c","d","e","f","g","h"]
Your problem is that "organizations" should be an array, not an object. It's like a list of companies. Instead, you should to have something like this :
You can also import this json in your root database example_root_firebase.json.zip
Get() and Once() must always return the same value :
["a","b","c","d","e","f","g","h"]
but after a subscription on a parent, the result of Get() becomes :
{"city":"Lyon","country":"France","data":["a","b","c","d","e","f","g","h"],"foo":"bar","id":0,"name":"my organization"}
I see, thanks. I updated the db to have the root node to be an array and then ran the code sample again which gives me same results as you mentioned above:
{"city":"Lyon","country":"France","data":["a","b","c","d","e","f","g","h"],"foo":"bar","id":0,"name":"my organization"}
Hi @darshankawar I've added a comment on @Lyokone 's PR : https://github.com/firebase/flutterfire/pull/10182#issuecomment-1403825724
Is there anything else we can do on our end regarding this issue? Thanks.
Is there anything else we can do on our end regarding this issue?
I think Guillaume should be aware of your comment in that PR and since you have tagged him in it, he'll probably let you know if there's anything else required from your end.
Sounds good, we'll wait :)
Hello, I don't know why OP hasn't back but I am having the same exact issue.
In my case I'm attaching a listener using
ref.child("a/path/to/data").onValue.listen((event) {
/// Then here I execute a callback function that redirects the user to another page
}
then a subsequent read from a child path such as: ref.child("a/path/to/data/child/node").get()
Will return the wrong data, at the parent path "a/path/to/data"
If I run the following:
StreamSubscription<DatabaseEvent>? sub;
sub = ref.child("a/path/to/data").onValue.listen((event) {
sub?.cancel();
/// Then here I execute a callback function that redirects the user to another page
}
then a subsequent read from a child path such as: ref.child("a/path/to/data/child/node").get()
will return the correct data at the parent path "a/path/to/data/child/node"
This is the behaviour running on an iPhone 15 Pro simulator with:
environment:
sdk: ">=3.1.1 <4.0.0"
dependencies:
firebase_database: ^10.2.7
Thank you for the report, I have opened an issue on the Firebase iOS SDK: https://github.com/firebase/firebase-ios-sdk/issues/12225
The same problem happens to me when using _organizationRef.keepSynced(true)
In fact, the SET method also writes to the wrong path.
Removing keepSynced the problem does not occur.
Bug report
This report relate to issue #9067 If I subscribe to a database reference, call get() function on a child reference will return wrong value in iOS. On Android it works as expected. A workaround exist using once() but it hasn't exactly the same behavior as get().
Steps to reproduce
Create new firebase project and put this in the root database
Create new Flutter project and configure it with your firebase project
Paste this in your main.dart
Expected behavior
I want to get the value of the key 'data'. The expected value is
["a","b","c","d","e","f","g","h"]
Calling get() or once() should return the same value.But if a suscription is made on the parent, the get() function will return the suscription's value. And once() return the correct value
This problem doesn't exist when I run on an android device
Sample project
sample_project
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` Doctor summary (to see all details, run flutter doctor -v): [β] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale fr-FR) [β] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [β] Xcode - develop for iOS and macOS (Xcode 14.2) [β] Chrome - develop for the web [β] Android Studio (version 2021.3) [β] VS Code (version 1.74.1) [β] Connected device (4 available) [β] HTTP Host Availability ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` Dart SDK 2.18.6 Flutter SDK 3.3.10 test_firebase 1.0.0+1 dependencies: - cupertino_icons 1.0.5 - firebase_core 2.4.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_database 10.0.7 [firebase_core firebase_core_platform_interface firebase_database_platform_interface firebase_database_web flutter] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] dev dependencies: - flutter_lints 2.0.1 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] transitive dependencies: - _flutterfire_internals 1.0.10 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - async 2.9.0 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - characters 1.2.1 - clock 1.1.1 - cloud_firestore_platform_interface 5.9.2 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.1.1 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.16.0 - fake_async 1.3.1 [clock collection] - firebase_core_platform_interface 4.5.2 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.0.2 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_database_platform_interface 0.2.2+15 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_database_web 0.2.1+17 [firebase_core firebase_core_web firebase_database_platform_interface flutter flutter_web_plugins js] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - js 0.6.4 - lints 2.0.1 - matcher 0.12.12 [stack_trace] - material_color_utilities 0.1.5 - meta 1.8.0 - path 1.8.2 - plugin_platform_interface 2.1.3 [meta] - sky_engine 0.0.99 - source_span 1.9.0 [collection path term_glyph] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.1 [source_span] - term_glyph 1.2.1 - test_api 0.4.12 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - vector_math 2.1.2 ```