File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
lib/active_record/relation Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change
1
+ * Allow ActiveRecord::QueryMethods#reselect to receive hash values, similar to ActiveRecord::QueryMethods#select
2
+
3
+ * Sampat Badhe*
4
+
1
5
* Validate options when managing columns and tables in migrations.
2
6
3
7
If an invalid option is passed to a migration method like ` create_table ` and ` add_column ` , an error will be raised
Original file line number Diff line number Diff line change @@ -406,6 +406,7 @@ def with!(*args) # :nodoc:
406
406
# Note that we're unscoping the entire select statement.
407
407
def reselect ( *args )
408
408
check_if_method_has_arguments! ( __callee__ , args )
409
+ args = process_select_args ( args )
409
410
spawn . reselect! ( *args )
410
411
end
411
412
Original file line number Diff line number Diff line change @@ -80,6 +80,18 @@ def test_reselect_with_default_scope_select
80
80
assert_equal expected , actual
81
81
end
82
82
83
+ def test_reselect_with_hash_argument
84
+ expected = Post . select ( :title , posts : { title : :post_title } ) . to_sql
85
+ actual = Post . select ( :title , :body ) . reselect ( :title , posts : { title : :post_title } ) . to_sql
86
+ assert_equal expected , actual
87
+ end
88
+
89
+ def test_reselect_with_one_level_hash_argument
90
+ expected = Post . select ( :title , title : :post_title ) . to_sql
91
+ actual = Post . select ( :title , :body ) . reselect ( :title , title : :post_title ) . to_sql
92
+ assert_equal expected , actual
93
+ end
94
+
83
95
def test_non_select_columns_wont_be_loaded
84
96
posts = Post . select ( "UPPER(title) AS title" )
85
97
You can’t perform that action at this time.
0 commit comments