Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix: habtm doesn't respect select query method #3030

Merged
merged 1 commit into from

3 participants

@jonleighton jonleighton merged commit 5767609 into from
@stve stve referenced this pull request from a commit
Miles Egan make sure request parameters are accessible after rack throws an exce…
…ption parsing the query string [#3030 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
3eff729
@spastorino

Fixed 85f8458 :)

Thanks, @spastorino :)

I think the fix also need to be brought to master since this commit is also in master (89e98e2).

Collaborator

Sorry @spastorino, I was sleeping in my time zone ;)

:heart: as soon as I complaint, I realized that was easier to fix it than complaining ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 15, 2011
  1. @htanata

    Fix: habtm doesn't respect select query method.

    htanata authored
    Patch for issue #2923.
This page is out of date. Refresh to see the latest.
View
4 activerecord/lib/active_record/associations/association_scope.rb
@@ -42,10 +42,6 @@ def select_value
select_value ||= options[:uniq] && "DISTINCT #{reflection.quoted_table_name}.*"
end
- if reflection.macro == :has_and_belongs_to_many
- select_value ||= reflection.klass.arel_table[Arel.star]
- end
-
select_value
end
View
8 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -647,6 +647,14 @@ def test_habtm_respects_select
assert_respond_to categories(:technology).select_testing_posts.find(:first), :correctness_marker
end
+ def test_habtm_selects_all_columns_by_default
+ assert_equal Project.column_names, developers(:david).projects.first.attributes.keys
+ end
+
+ def test_habtm_respects_select_query_method
+ assert_equal ['id'], developers(:david).projects.select(:id).first.attributes.keys
+ end
+
def test_join_table_alias
assert_equal 3, Developer.find(:all, :include => {:projects => :developers}, :conditions => 'developers_projects_join.joined_on IS NOT NULL').size
end
View
8 activerecord/test/cases/associations/has_many_associations_test.rb
@@ -485,6 +485,14 @@ def test_find_scoped_grouped_having
assert_equal 0, authors(:mary).popular_grouped_posts.length
end
+ def test_default_select
+ assert_equal Comment.column_names, posts(:welcome).comments.first.attributes.keys
+ end
+
+ def test_select_query_method
+ assert_equal ['id'], posts(:welcome).comments.select(:id).first.attributes.keys
+ end
+
def test_adding
force_signal37_to_load_all_clients_of_firm
natural = Client.new("name" => "Natural Company")
Something went wrong with that request. Please try again.