-
Notifications
You must be signed in to change notification settings - Fork 131
V3: orderByChild + startAt or endAt #174
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
Comments
Hmm weird one @florianbepunkt - database in the current pushed up state of my branch has not been touched bar a PR from @BlooJeans which was on master that I manually pulled in. Will look at this today and get back to you, the example helps, cheers! |
@florianbepunkt looks like @chrisbianca fixed this issue 3 days ago on my branch - have you tried pulling the latest? This commit: |
@Salakar I did. To make sure I just installed it again via The commit only changes things on android side… I see this problem with iOS. |
I only updated the Android side as that's where I'd noticed the issue. |
@florianbepunkt oh ok my bad, thought you were having an android issue sorry. @chrisbianca that would be awesome thanks! |
I'm not sure if this is related… using a fresh install from Salakar's fork I see the same issue on android. Using my sample data
returns zero values… |
Ok, I don't have any data setup to test this with at the moment. |
@chrisbianca okay. I throw together a simple test project and upload it if that helps |
@florianbepunkt that would be great! |
@chrisbianca @Salakar Okay, here we go… https://github.com/florianbepunkt/fireStackQuery you can clone the repo, run npm install and run it. I've tested it on ios and it reproduces the issue. |
So I've figured out why it's broken in Java... It's passing the startAt and endAt as a String rather than a number. The fix is an awful lot of repetitive code but I can't think of a better way to work around it! Just pushed the fix to the v3 branch and sorted for boolean types too. Will try and look at iOS now... |
@chrisbianca great! just checked android version with your commit |
I've just committed the equivalent fix for iOS. I rewrote a large part of the iOS database module to bring it more in line with Android and stop regenerating firebase references unnecessarily. Let me know if you have any other issues... |
@chrisbianca I just freshly cloned my example project linked above and run this is the output of
|
@florianbepunkt Ah yes, for the time being, add the following in your AppDelegate.m: At the top:
In
I'll look at why Firebase isn't being initialised before the database later today / tomorrow |
@chrisbianca Thank you. This did the trick |
@florianbepunkt Just pushed a change so you shouldn't need to configure your app in the iOS code anymore |
@chrisbianca First of all thank you. I feel a bit lost here… in my demo example I linked above, this works. When I put it in my app I'm working on, startAt and endAt have no effect. I made sure I updated firestack… it's up to date. and it's the same data set. any idea how this can happen? |
@chrisbianca okay, got it working now. I had to delete the ios build folder. either I messed up my xcode project settings or when you run the app it's not built from scratch… anyway it works now 👍 I found a small error by accident … I'm working on a kind of messenger. so when I open a conversation I attach a listener for messages, when I leave the conversation I detach the listener by calling
by accident I called the code above without attaching a listener first...which throws the error below. has the method for detaching a listener changed? anyways for me it's no issue, just wanted to let you know.
|
@florianbepunkt I haven't changed anything around the off() functionality so this may be a pre-existing issue. I believe @Salakar is going to look at the JS side of the database and try and simplify the listeners so may cover this then. |
Okay. I did not notice this error before the update.… i did some more testing. I also get this error when I properly atatched a listener first… so basically whenever I remove a listener. |
@florianbepunkt Try:
Everytime you modify the reference (adding modifiers or changing the path), it effectively creates a new unique reference. Two references that have the same 'builder' are not the same internally. |
@BlooJeans Thanks for the clarification. Makes sense. |
@florianbepunkt @chrisbianca - @Ehesp and I are having the same issue at the moment: firestack
.database()
.ref('matches')
.orderByChild('startsAt')
.startAt(1480982400)
.endAt(1481068799)
.on('value', snap => console.log(snap.val())); Returns no results on firestack. The exact same query however on the web sdk returns correctly and gives We're using the head of my fork which includes your changes @chrisbianca - am i missing something? A possibly better way to handle the value types would be get the types on the JS side i.e. it gets sent over as Sorry for the slow responses also, have been ill, urgh. |
@Salakar I can confirm (sorry @chrisbianca didn't notice since I had no need to combine startAt and endAt yet) although I get results, when I combine startAt and endAt both queries below return the same results. updated my test project https://github.com/florianbepunkt/fireStackQuery
|
@florianbepunkt thanks, we've been discussing off this thread and I'm just working on a fix |
@chrisbianca alright. just fyi: I tested above only on ios. if I can help in any way let me know. |
@florianbepunkt I've just pushed a fix which I've tested on iOS. Would be great if you're able to confirm that it's working for you now too |
@chrisbianca works on ios. tested orderByChild with startAt, endAt and both combined. |
Excellent! @Salakar when you're happy, I think this can be closed again |
Also works on my end. Nice one 👍 (Android) |
Closing issue as it's now resolved completely 👍 |
There is something bizarre happening here, this same error is happening only in the iPhone 5, both in the simulator and on a real device as well, I am on Salakar's branch, has anyone ever tested on an iPhone 5 before and got this error? |
I am still not getting the expected results. firestack.database
.ref('events')
.orderByChild('timestamp')
.endAt(1490331248253)
.once('value')
.then((snapshot) => {
console.log('queryTest orderByChild endAt test > snapshot', snapshot);
}) This returns all results rather than stopping at the timestamp provided. The following provides no results at all despite having records in the database that have those exact timestamps: firestack
.database
.ref('events')
.orderByChild('timestamp')
.startAt(1490331248253 )
.endAt(1490331422094)
.once('value')
.then((snapshot) => {
console.log('queryTest orderByChild startAt and endAt test > snapshot', snapshot);
}) @chrisbianca What push are you referring to? Can you link to the commit? ping: @Salakar |
@AndrewHenderson the above mentioned fixes happened on the v3 version of firestack, your code above looks like you're currently using the old firestack version. e.g. v3 was my fork: https://github.com/Salakar/react-native-firestack |
@Salakar Sorry to bother you again. It seems like orderByChild is not working, at least when used with startAt or endAt. I have a list of message objects that I want to query based on their timestamp.
This code returns zero results
while this code returns all results
Based on my sample data below…both results are wrong. The first example should return the first last two objects, the second example should return the first two objects.
I tried both the v3 branch of this repo as well as master branch of your fork. Based on the sample data the query above should return the first object. But nothing is returned
The text was updated successfully, but these errors were encountered: