Skip to content
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

$has queries break if test value coerces to/is false #17

Merged
merged 1 commit into from
Oct 29, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions out/lib/query-engine.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions out/test/queries.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/lib/query-engine.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ util =
result = []

# Determine the correct type
if value
valueExists = typeof value isnt 'undefined'
if valueExists
if util.isArray(value)
result = value
else if util.isObject(value)
Expand All @@ -142,7 +143,8 @@ util =
result = []

# Determine the correct type
if value
valueExists = typeof value isnt 'undefined'
if valueExists
if util.isArray(value)
result = value
else if util.isObject(value)
Expand Down
7 changes: 6 additions & 1 deletion src/test/queries.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@ generateTestSuite = (describe, it, name,docs) ->
actual = docs.findAll date: $lte: today
expected = queryEngine.createCollection 'index': docs.get('index'), 'jquery': docs.get('jquery')
assert.deepEqual actual.toJSON(), expected.toJSON()


it '$has-false', ->
actual = docs.findAll good: $has: false
expected = queryEngine.createCollection 'jquery': docs.get('jquery')
assert.deepEqual actual.toJSON(), expected.toJSON()

it 'all', ->
actual = docs
expected = docs
Expand Down