directiverecord 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmEyYjEwZjExYzg4OTE0ZjE2MTc5NjhmNTU4NzgyOGFhZGY5MzVhZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjQxZDk5OGUyMWU2MjkyZTcyNTA5Yzc3OTFhOTY5OWU0ZDU3YjQyYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTgzNDFjMGJmNTY5ZTcxN2Q5ZjRmNDhlMTIwZDA2Y2RjMTI0YTRjN2YzMmI0
|
10
|
+
Yjk0NjM5Zjc2ZmNhMmEwNzY2YjkxOThlZjA1YzBmYzQ4YmI4NDI4NTg3YjBh
|
11
|
+
MmZhZDliY2Y3YzBjMDM2NTNjMjZlMTVkZWRkYzllNjU2MGQ1ZTM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWMwODE0ZjUxZTJiOGExMjhkODBjM2JlZjhkZjg0YWNkNmUzNTM2Mjc0YTYy
|
14
|
+
MDUxZWM1MmYzYWE1MDA5ZjA4NjYxMGUyNDhiNDZkYjA5YWEzNzcwMTBkZGJl
|
15
|
+
NGQxOTZhOWVkZmVhOGY5Y2E1NmVjOWMzODRlMTZjNzU4YTI1M2Q=
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
= DirectiveRecord CHANGELOG
|
2
2
|
|
3
|
+
== Version 0.1.16 (March 12, 2015)
|
4
|
+
|
5
|
+
* Made ActiveRecord::Relation#count(:all) override more strict: only overrule behavior when having detected a possible path in the query options
|
6
|
+
|
3
7
|
== Version 0.1.15 (March 10, 2015)
|
4
8
|
|
5
9
|
* Being able to include / exclude subselect options
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.16
|
@@ -17,10 +17,23 @@ module ActiveRecord
|
|
17
17
|
|
18
18
|
def count(column_name = nil, options = {})
|
19
19
|
if !loaded? && (column_name == :all) && (options == {})
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
associations = klass.reflections.keys.collect(&:to_s)
|
21
|
+
|
22
|
+
contains_possible_paths = qry_options.any? do |key, value|
|
23
|
+
if value.is_a?(Array)
|
24
|
+
value.any? do |val|
|
25
|
+
val.to_s.scan(/(?:^|[^\.])([a-z_]+)\.[a-z_]+/).flatten.any? do |string|
|
26
|
+
associations.include?(string)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if contains_possible_paths
|
33
|
+
return qry("COUNT(DISTINCT id)")[0][0]
|
34
|
+
end
|
23
35
|
end
|
36
|
+
original_count column_name, options
|
24
37
|
end
|
25
38
|
|
26
39
|
end
|
@@ -45,10 +45,26 @@ module Unit
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
describe "when not loaded" do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
describe "when not having potential path query options" do
|
49
|
+
it "invokes the original count method" do
|
50
|
+
@relation.expects(:loaded?).returns(false)
|
51
|
+
@relation.expects(:qry_options).returns({:where => ["foo = 12"]})
|
52
|
+
@relation.expects(:original_count)
|
53
|
+
@relation.count(:all)
|
54
|
+
|
55
|
+
@relation.expects(:loaded?).returns(false)
|
56
|
+
@relation.expects(:qry_options).returns({:where => ["foo.bar = 12"]})
|
57
|
+
@relation.expects(:original_count)
|
58
|
+
@relation.count(:all)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
describe "when having potential path query options" do
|
62
|
+
it "uses #qry to count the records" do
|
63
|
+
@relation.expects(:loaded?).returns(false)
|
64
|
+
@relation.expects(:qry_options).returns({:where => ["employees.foo = 12"]})
|
65
|
+
@relation.expects(:qry).with("COUNT(DISTINCT id)").returns([[1982]])
|
66
|
+
assert_equal 1982, @relation.count(:all)
|
67
|
+
end
|
52
68
|
end
|
53
69
|
end
|
54
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: directiverecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Engel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|