where_exists 0.9 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/where_exists.rb +2 -5
- data/lib/where_exists/version.rb +1 -1
- data/test/db/test.db +0 -0
- data/test/has_many_through_test.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e6f042ea66ced8e828fa202fe84705b55846641
|
4
|
+
data.tar.gz: b28d7eaf45be811108a93108355ce05c2ca5f2d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc5ccf9d5987400e2533b60bbef83b5643a23f7e2780b1e8db83546f2838eb239fb43bb3e1f9ae7e4738255d390a21f25ea989c1cf1afa88fc72b0483ae25baa
|
7
|
+
data.tar.gz: 96255b728f3de38c8d48298eac8a6eb53b78550eb985cc37ccb3f9d93b31ea68f86171a89708b9f6a59260bd2bf22b9e0c43f29969c20e3ccf91114f4b190483
|
data/lib/where_exists.rb
CHANGED
@@ -71,7 +71,7 @@ module WhereExists
|
|
71
71
|
through = association.options[:through].present?
|
72
72
|
|
73
73
|
if through
|
74
|
-
|
74
|
+
next_association = association.source_reflection
|
75
75
|
association = association.through_reflection
|
76
76
|
end
|
77
77
|
|
@@ -89,10 +89,7 @@ module WhereExists
|
|
89
89
|
end
|
90
90
|
|
91
91
|
if through
|
92
|
-
|
93
|
-
original_association_name = original_association_name.to_s.singularize.to_sym
|
94
|
-
end
|
95
|
-
result = result.where_exists(original_association_name, where_parameters)
|
92
|
+
result = result.where_exists(next_association.name, where_parameters)
|
96
93
|
else
|
97
94
|
result = result.where(where_parameters)
|
98
95
|
end
|
data/lib/where_exists/version.rb
CHANGED
data/test/db/test.db
CHANGED
Binary file
|
@@ -22,7 +22,7 @@ end
|
|
22
22
|
class Project < ActiveRecord::Base
|
23
23
|
has_many :tasks
|
24
24
|
has_many :invoices, :through => :tasks
|
25
|
-
has_many :
|
25
|
+
has_many :project_line_items, :through => :tasks, :source => :line_items
|
26
26
|
end
|
27
27
|
|
28
28
|
class Task < ActiveRecord::Base
|
@@ -59,12 +59,12 @@ class HasManyThroughTest < Minitest::Unit::TestCase
|
|
59
59
|
line_item = LineItem.create!(name: 'relevant', task: task)
|
60
60
|
irrelevant_line_item = LineItem.create!(name: 'irrelevant', task: irrelevant_task)
|
61
61
|
|
62
|
-
result = Project.where_exists(:
|
62
|
+
result = Project.where_exists(:project_line_items, name: 'relevant')
|
63
63
|
|
64
64
|
assert_equal 1, result.length
|
65
65
|
assert_equal project.id, result.first.id
|
66
66
|
|
67
|
-
result = Project.where_not_exists(:
|
67
|
+
result = Project.where_not_exists(:project_line_items, name: 'relevant')
|
68
68
|
assert_equal 1, result.length
|
69
69
|
assert_equal irrelevant_project.id, result.first.id
|
70
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: where_exists
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Zolotarev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|