Actually fix the issue, rather than pretending to
This commit is contained in:
parent
2e70cc5d99
commit
e8de5907fa
|
@ -7,7 +7,7 @@ When /^I chain a where clause onto that query$/ do
|
|||
end
|
||||
|
||||
Then /^the original query should remain unchanged$/ do
|
||||
@query.should_not eql @new_query
|
||||
@query.opts({}).should_not eql @new_query.opts({})
|
||||
end
|
||||
|
||||
Then /^should initialize with an attribute and an operator$/ do
|
||||
|
|
|
@ -80,31 +80,27 @@ module Middleman
|
|||
selector = Selector.new(:attribute => attribute, :operator => 'equal')
|
||||
selector_hash.update({ selector => value })
|
||||
end
|
||||
@where.merge! selector_hash
|
||||
Query.new @model, opts
|
||||
Query.new @model, opts(:where => @where.merge(selector_hash))
|
||||
end
|
||||
|
||||
def opts
|
||||
{ :where => @where,
|
||||
def opts new_opts
|
||||
{ :where => {}.merge(@where),
|
||||
:order_by => @order_by,
|
||||
:offset => @offset,
|
||||
:limit => @limit
|
||||
}
|
||||
}.merge(new_opts)
|
||||
end
|
||||
|
||||
def order_by(field)
|
||||
@order_by = field.is_a?(Symbol) ? {field => :asc} : field
|
||||
Query.new @model, opts
|
||||
Query.new @model, opts(:order_by => field.is_a?(Symbol) ? {field => :asc} : field)
|
||||
end
|
||||
|
||||
def offset(number)
|
||||
@offset = number
|
||||
Query.new @model, opts
|
||||
Query.new @model, opts(:offset => number)
|
||||
end
|
||||
|
||||
def limit(number)
|
||||
@limit = number
|
||||
Query.new @model, opts
|
||||
Query.new @model, opts(:limit => number)
|
||||
end
|
||||
|
||||
def first
|
||||
|
|
Loading…
Reference in a new issue