ilovesoup / asterixdb

Automatically exported from code.google.com/p/asterixdb
0 stars 0 forks source link

Wrong results are returned upon asking for an item which doesn't exist #762

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The three examples (Ex 1-3) return null which is good, Ex 4-5  return 0 and "" 
instead of a null. This seems to be a type bug.

Ex 1. let $list :=[ 1, 2, 3]
return $list [4]

Ex 2. let $list :=[ {"foo":1},{"foo":2},{"toto":3}]
return $list [2].foo

Ex 3. {}.foo

==> all three examples return a null which is good.

However, Ex 4 below should return a null and actually returns a 0. 
Ex 4. let $list :=[ {"foo":1},{"foo":2},{"foo":3}]
return $list [4].foo

Also Ex 5. below should return a null and actually returns a "".
Ex 5: let $list :=[ {"foo":"1"},{"foo":"2"},{"foo":"3"}]
return $list [4].foo

Original issue reported on code.google.com by ker...@gmail.com on 25 Apr 2014 at 12:21

GoogleCodeExporter commented 9 years ago
Seems like the issue here is that the contents of ordered list are enforced to 
have type {"foo":int32\string}, hence the int32\string printer would be used to 
return result, irrespective from the fact that the result is null.
Possible solutions include:
1) Revisiting applicability of IntroduceEnforcedListTypeRule rewrite
2) Extending print writers to check the type tag of the result, and return null 
in case when it is 14 (null type tag) 

Original comment by ildar.absalyamov on 25 Oct 2014 at 11:16