File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ * Fix unscope is not working in specific case
2
+
3
+ Before:
4
+ ``` ruby
5
+ Post .where(id: 1 ...3 ).unscope(where: :id ).to_sql # "SELECT `posts`.* FROM `posts` WHERE `posts`.`id` >= 1 AND `posts`.`id` < 3"
6
+
7
+ ```
8
+
9
+ After:
10
+ ` ` ` ruby
11
+ Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT ` posts` .* FROM ` posts` "
12
+ ` ` `
13
+
14
+ Fixes # 48094.
15
+
16
+ * Kazuya Hatanaka *
17
+
1
18
* Change ` has_secure_token` default to ` on: :initialize`
2
19
3
20
Change the new default value from ` on: :create` to ` on: :initialize`
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ def right
18
18
children [ 1 ]
19
19
end
20
20
21
+ def fetch_attribute ( &block )
22
+ children . any? && children . all? { |child | child . fetch_attribute ( &block ) }
23
+ end
24
+
21
25
def hash
22
26
children . hash
23
27
end
Original file line number Diff line number Diff line change @@ -2329,6 +2329,20 @@ def test_unscope_grouped_where
2329
2329
assert_equal Post . count , posts . unscope ( where : :title ) . count
2330
2330
end
2331
2331
2332
+ def test_unscope_with_double_dot_where
2333
+ posts = Post . where ( id : 1 ..2 )
2334
+
2335
+ assert_equal 2 , posts . count
2336
+ assert_equal Post . count , posts . unscope ( where : :id ) . count
2337
+ end
2338
+
2339
+ def test_unscope_with_triple_dot_where
2340
+ posts = Post . where ( id : 1 ...3 )
2341
+
2342
+ assert_equal 2 , posts . count
2343
+ assert_equal Post . count , posts . unscope ( where : :id ) . count
2344
+ end
2345
+
2332
2346
def test_locked_should_not_build_arel
2333
2347
posts = Post . locked
2334
2348
assert_predicate posts , :locked?
You can’t perform that action at this time.
0 commit comments