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
|
end
|
||||||
|
|
||||||
Then /^the original query should remain unchanged$/ do
|
Then /^the original query should remain unchanged$/ do
|
||||||
@query.should_not eql @new_query
|
@query.opts({}).should_not eql @new_query.opts({})
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should initialize with an attribute and an operator$/ do
|
Then /^should initialize with an attribute and an operator$/ do
|
||||||
|
|
|
@ -80,31 +80,27 @@ module Middleman
|
||||||
selector = Selector.new(:attribute => attribute, :operator => 'equal')
|
selector = Selector.new(:attribute => attribute, :operator => 'equal')
|
||||||
selector_hash.update({ selector => value })
|
selector_hash.update({ selector => value })
|
||||||
end
|
end
|
||||||
@where.merge! selector_hash
|
Query.new @model, opts(:where => @where.merge(selector_hash))
|
||||||
Query.new @model, opts
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def opts
|
def opts new_opts
|
||||||
{ :where => @where,
|
{ :where => {}.merge(@where),
|
||||||
:order_by => @order_by,
|
:order_by => @order_by,
|
||||||
:offset => @offset,
|
:offset => @offset,
|
||||||
:limit => @limit
|
:limit => @limit
|
||||||
}
|
}.merge(new_opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def order_by(field)
|
def order_by(field)
|
||||||
@order_by = field.is_a?(Symbol) ? {field => :asc} : field
|
Query.new @model, opts(:order_by => field.is_a?(Symbol) ? {field => :asc} : field)
|
||||||
Query.new @model, opts
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def offset(number)
|
def offset(number)
|
||||||
@offset = number
|
Query.new @model, opts(:offset => number)
|
||||||
Query.new @model, opts
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def limit(number)
|
def limit(number)
|
||||||
@limit = number
|
Query.new @model, opts(:limit => number)
|
||||||
Query.new @model, opts
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def first
|
def first
|
||||||
|
|
Loading…
Reference in a new issue