Skip to content

Commit

Permalink
v1.1.11. We now throw error is setters are called incorrectly.
Browse files Browse the repository at this point in the history
- v1.1.11 May 17, 2012
	- We now throw errors if `QueryCollection::setFilter`,
`QueryCollection::setQuery`, and `QueryCollection::setPill` are called
without both arguments
  • Loading branch information
balupton committed May 22, 2012
1 parent be4eb7d commit 3083c95
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions History.md
@@ -1,5 +1,8 @@
## History

- v1.1.11 May 17, 2012
- We now throw errors if `QueryCollection::setFilter`, `QueryCollection::setQuery`, and `QueryCollection::setPill` are called without both arguments

- v1.1.10 May 17, 2012
- Added sorting on change events if the collection is live
- Fixed sorting by a value that could be 0
Expand Down
12 changes: 10 additions & 2 deletions lib/query-engine.coffee
Expand Up @@ -197,6 +197,9 @@ class QueryCollection extends Backbone.Collection

# Set Filter
setFilter: (name,value) ->
# Check we have been called with both arguments
throw new Error('QueryCollection::setFilter was called without both arguments') if typeof value is 'undefined'

# Prepare
filters = @options.filters

Expand Down Expand Up @@ -230,6 +233,9 @@ class QueryCollection extends Backbone.Collection

# Set Query
setQuery: (name,value) ->
# Check we have been called with both arguments
throw new Error('QueryCollection::setQuery was called without both arguments') if typeof value is 'undefined'

# Prepare
queries = @options.queries

Expand Down Expand Up @@ -264,6 +270,9 @@ class QueryCollection extends Backbone.Collection

# Set Pill
setPill: (name,value) ->
# Check we have been called with both arguments
throw new Error('QueryCollection::setPill was called without both arguments') if typeof value is 'undefined'

# Prepare
pills = @options.pills
searchString = @options.searchString
Expand Down Expand Up @@ -450,8 +459,7 @@ class QueryCollection extends Backbone.Collection

# Create Child Collection
createChildCollection: ->
collection = new QueryCollection()
.setParentCollection(@)
collection = new QueryCollection().setParentCollection(@)
collection.comparator ?= @comparator if @comparator
return collection

Expand Down
9 changes: 9 additions & 0 deletions lib/query-engine.js

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

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "query-engine",
"version": "1.1.10",
"version": "1.1.11",
"description": "Query-Engine is a NoSQL and MongoDb compliant query engine. It can run on the server-side with Node.js, or on the client-side within web browsers",
"homepage": "https://github.com/bevry/query-engine",
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions test/queries.coffee
Expand Up @@ -214,8 +214,8 @@ generateTestSuite = (name,docs) ->
assert.deepEqual actual.toJSON(), expected.toJSON()

it 'findOne', ->
actual = docs.findOne()
expected = docs.get('index')
actual = docs.findOne(tags: $has: 'jquery')
expected = docs.get('jquery')
assert.deepEqual actual.toJSON(), expected.toJSON()

# Generate Suites
Expand Down

0 comments on commit 3083c95

Please sign in to comment.