Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

BUG Database query - range not working when value is number. #87

Closed
IvRRimum opened this issue Jul 26, 2016 · 8 comments
Closed

BUG Database query - range not working when value is number. #87

IvRRimum opened this issue Jul 26, 2016 · 8 comments
Assignees
Milestone

Comments

@IvRRimum
Copy link

So, this is wierd.

So i have this structure:
0:
category_id: 1
date: "dsasad"
deleted: false
description: "This is some stuff - this is quite wierd."
id: 1
path: "/uploads/user/images/1.png"
user_id: "Bulgaria"

When i try query it with:

157     firebase.query(
158         zonedCallback(onQueryEvent.bind(this)),
159         "/photos",
160         {
161             singleEvent: false,
162             orderBy: {
163                 type: firebase.QueryOrderByType.CHILD,
164                 value: 'category_id'
165             },
166 
167             range: {
168                 type: firebase.QueryRangeType.EQUAL_TO,
169                 value: '1'
170             },  
171                 
172             limit: {
173                 type: firebase.QueryLimitType.LAST,
174                 value: 20
175             }
176         }
177     )


When i change firebase category_id to "1"( instead of just 1 ), then it works. If i try to change value: 1, then console errors out.

@EddyVerbruggen
Copy link
Owner

I just tried this on both iOS and Android and didn't encounter an issue. In my database I tried with both Integer and String types, and set the type of the range property accordingly. So if the type is Integer in the DB the range query is 1, instead of '1'. This works as expected for me.

Note that I erased the DB contents in between tests to make sure the types in the DB are correctly set.

I tested on an iPhone 6s device and an Android S3 (running Android 4.4) simulator.

Any idea what's different on your end?

@sivsushruth
Copy link

Even I am facing the above issue

@EddyVerbruggen
Copy link
Owner

@sivsushruth Would you be so kind to share some details as well?

@GrEg00z
Copy link

GrEg00z commented Jun 13, 2017

Same problem here, while using this :

firebase.query(({ type, key, value }) => {
        // .......
      }, ref, {
         orderBy: {
          type: firebase.QueryOrderByType.CHILD,
          value: 'status'
		},
	ranges: [
		{
		       type: firebase.QueryRangeType.START_AT,
		       value: 0
		},
		{
			type: firebase.QueryRangeType.END_AT,
			value: 1
		}
	]
	// OR using (not both ranges & range)
	range: {
          type: firebase.QueryRangeType.EQUAL_TO,
          value: 0
	}
}).then(({ listeners }) => {
	queryListeners = listeners;
}).catch(observer.error);

Then I get the following error :

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'isStopped' of undefined

If I use string inside range value, there is no bug

@EddyVerbruggen
Copy link
Owner

@GrEg00z is isStopped a value in your database? If so, can you share the structure/data?

@GrEg00z
Copy link

GrEg00z commented Jun 13, 2017

It was an error from my part, now it works good !

Sorry for this

@EddyVerbruggen
Copy link
Owner

If there is still an issue for other folks, please upgrade to 4.0.0 (which I'm releasing later today).

@GrEg00z
Copy link

GrEg00z commented Jul 12, 2017

I don't understant why, but the problem comes back for me, exactly in the same context than my previous post :

Same problem here, while using this :

firebase.query(({ type, key, value }) => {
// .......
}, ref, {
orderBy: {
type: firebase.QueryOrderByType.CHILD,
value: 'status'
......................................

So if I use number value instead of string value in ranges array , I get the following error :

TypeError: Cannot read property 'isStopped' of undefined
	at Subscriber.error (file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/rxjs/Subscriber.js:100:18)
	at ZoneDelegate.invoke (file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:365:26)
	at Object.onInvoke (file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/@angular/core/bundles/core.umd.js:4132:37)
	at ZoneDelegate.invoke (file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:364:32)
	at Zone.run (file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:125:43)
	at file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:760:57
	at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:398:31)
	at Object.onInvokeTask (file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/@angular/core/bundles/core.umd.js:4123:37)
	at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:397:36)
	at Zone.runTask (file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:165:47)
	at drainMicroTaskQueue (file:///data/data/org.nativescript.Nowgua/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:593:35)

I've updated to 4.0.3, I get the same problem.

If I use range instead of ranges, then it only working with string value.
While using number value, there is no error thrown, but no data are received

The problem seems to come only when we have numeric value in firebase data, and try to request on this properties

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants