[SERVER-864] $where queries involving an attribute with the word "return" anywhere in the name returns nothing Created: 02/Apr/10  Updated: 12/Jul/16  Resolved: 08/Apr/10

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.3.1, 1.4.0
Fix Version/s: 1.5.0

Type: Bug Priority: Major - P3
Reporter: Patrick Gannon Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu Linux running inside VMWare server


Participants:

 Description   

If you use the word 'return' as an attribute name, or the word return is even part of any attribute name (like 'returned_date' or 'wesasreturningsa') then you will not be able to use the "$where" to filter on that attribute - you will get negative result (zero rows) under all circumstances, so "$where"=>"this.returned_date == null || this.returned_date != null" will still return zero rows, even though logically that is impossible. It may be some kind overly broad string matching in the mongo database's handling of "$where". You will not see this problem in a traditional filter or in the context of a map/reduce. To get around it without having to mangle your models, you can (unappetizingly) construct your where clause like this: "$where"=>"this['r' + 'eturned_date'] == 'whatever'"



 Comments   
Comment by Eliot Horowitz (Inactive) [ 26/Apr/10 ]

in a release

Comment by auto [ 08/Apr/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: fix where on v8 SERVER-864
http://github.com/mongodb/mongo/commit/48d2acc0de66704bce7fc20ca1f50cdf5c522a80

Comment by Aaron Staple [ 08/Apr/10 ]

seems to be failing in v8?
<http://buildbot.mongodb.org/builders/Linux%2064-bit%20v8/builds/427/steps/test/logs/stdio>

Comment by auto [ 02/Apr/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: make return parsing smarter SERVER-864
http://github.com/mongodb/mongo/commit/44237031b1c0edec4ffc931aad1b8914de53ad5e

Comment by Eliot Horowitz (Inactive) [ 02/Apr/10 ]

will fix, but if you make it
"$where"=>"return this.returned_date == null || this.returned_date != null"
note: the added return at beginning of statement

then it will work as is

Generated at Thu Feb 08 02:55:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.