xAPI-Dashboard icon indicating copy to clipboard operation
xAPI-Dashboard copied to clipboard

Null and 0 comparison should probably not evaluate to true

Open mickmuzac opened this issue 10 years ago • 3 comments

The snippet below works as expected.

data.where('result.score.raw > 0').orderBy('result.score.raw');
data.where('result.score.raw >= 0 and result.score.raw != null').orderBy('result.score.raw');

However this: data.where('result.score.raw >= 0').orderBy('result.score.raw');

Results in: xapicollection.js:698 Uncaught TypeError: Cannot read property 'toLowerCase' of null.

Which leads me to believe that the Collection class evaluates 0 == null to true and includes statements with null (or undefined?) score values in the resultant collection. This should probably not happen.

mickmuzac avatar Mar 20 '15 15:03 mickmuzac

null >= 0
true

Upstream "bug" with ECMA 5. Maybe we could implement some >== that checks types?

stevenvergenz avatar Mar 23 '15 15:03 stevenvergenz

Yes. That's a very, very good idea.

I will file a number of issues with ECMA 5. Enough is enough.

mickmuzac avatar Mar 23 '15 15:03 mickmuzac

Since this hasn't been touched in awhile, just making note here that maybe a workaround could be adding typeof getVal(parse.xpath.stmt) === typeof parse.value && to lines 470 and 471 in xapicollection.js

ljwolford avatar Oct 05 '16 14:10 ljwolford