Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Revert "Updated Query#update's field mergining logic."
Browse files Browse the repository at this point in the history
This reverts commit e5df3f6.
  • Loading branch information
Dan Kubb committed Nov 30, 2008
1 parent f6b4f6b commit c1ef0ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
3 changes: 1 addition & 2 deletions lib/dm-core/query.rb
Expand Up @@ -51,11 +51,10 @@ def update(other)
@limit = other.limit unless other.limit == nil
@order = other.order unless other.order == model.default_order
@add_reversed = other.add_reversed? unless other.add_reversed? == false
@fields = other.fields unless other.fields == @properties.defaults
@links = other.links unless other.links == []
@includes = other.includes unless other.includes == []

@fields == @properties.defaults ? @fields = other.fields : @fields |= other.fields

update_conditions(other)

self
Expand Down
16 changes: 5 additions & 11 deletions spec/unit/query_spec.rb
Expand Up @@ -219,17 +219,6 @@ class Acl
@query.update(other).should == @query
end

it "should merge #fields if :fields != model.properties.defaults" do
other = DataMapper::Query.new(@repository, Article, :fields => [ :blog_id ])
@query.update(other).fields.should == Article.properties.slice(:id, :author, :blog_id)
end

it "should replace #fields if fields == model.properties.defaults" do
query = DataMapper::Query.new(@repository, Article, :fields => Article.properties.defaults.map { |property| property.name })
other = DataMapper::Query.new(@repository, Article, :fields => [ :blog_id ])
query.update(other).fields.should == Article.properties.slice(:blog_id)
end

describe 'should overwrite the attribute' do
it '#reload? with other reload?' do
other = DataMapper::Query.new(@repository, Article, :reload => true)
Expand Down Expand Up @@ -314,6 +303,11 @@ class Acl
end
end

it "#fields with other fields unique values" do
other = DataMapper::Query.new(@repository, Article, :fields => [ :blog_id ])
@query.update(other).fields.should == Article.properties.slice(:blog_id)
end

it '#conditions with other conditions when they are unique' do
# set the initial conditions
@query.update(:title => 'On DataMapper')
Expand Down

0 comments on commit c1ef0ff

Please sign in to comment.