join_dependency 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/lib/join_dependency/version.rb +1 -1
- data/lib/join_dependency.rb +22 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8cffecfd290bbbcbdcc598997b537acd52ff9f2afd2d2c3ba1cc372465ab956
|
4
|
+
data.tar.gz: fa9d90a857113b7e93ea2f3ce2e6eead3f777ee50b8541b74aa29f120e304780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e90bab34d75b8a8ca8b6d444b9d4bf1dea827bcbb5d2ef7ba4ad858a5f77d8520d4f06c576eec2702e540bd5806fb1d74fbb96f40e50ec5144cb89cdd1d30d74
|
7
|
+
data.tar.gz: 32413e65f2adb1a64d716a822ce849ee3f02c47e7272be2f1ca22315e403a725d994dd7f862d4c2806ab9a1d6f7c11c7377cd0cef19962b3e9de3bfe3ee53f3a
|
data/.travis.yml
CHANGED
data/lib/join_dependency.rb
CHANGED
@@ -37,21 +37,30 @@ module JoinDependency
|
|
37
37
|
join_nodes = buckets[:join_node].uniq
|
38
38
|
string_joins = buckets[:string_join].map(&:strip).uniq
|
39
39
|
|
40
|
+
joins = string_joins.map do |join|
|
41
|
+
table.create_string_join(Are.sql(join)) unless join.blank?
|
42
|
+
end.compact
|
43
|
+
|
40
44
|
join_list =
|
41
|
-
if at_least?(5
|
42
|
-
join_nodes +
|
43
|
-
elsif at_least?(5)
|
44
|
-
join_nodes + relation.send(:convert_join_strings_to_ast, relation.table, string_joins)
|
45
|
+
if at_least?(5)
|
46
|
+
join_nodes + joins
|
45
47
|
else
|
46
48
|
relation.send(:custom_join_ast, relation.table.from(relation.table), string_joins)
|
47
49
|
end
|
48
50
|
|
49
|
-
if
|
51
|
+
if exactly?(5, 2, 0)
|
50
52
|
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(relation.klass.connection, relation.table.name, join_list)
|
51
53
|
join_dependency = ::ActiveRecord::Associations::JoinDependency.new(relation.klass, relation.table, association_joins, alias_tracker)
|
52
54
|
join_nodes.each do |join|
|
53
55
|
join_dependency.send(:alias_tracker).aliases[join.left.name.downcase] = 1
|
54
56
|
end
|
57
|
+
elsif at_least?(5, 2, 1)
|
58
|
+
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(relation.klass.connection, relation.table.name, join_list)
|
59
|
+
join_dependency = ::ActiveRecord::Associations::JoinDependency.new(relation.klass, relation.table, association_joins)
|
60
|
+
join_dependency.instance_variable_set(:@alias_tracker, alias_tracker)
|
61
|
+
join_nodes.each do |join|
|
62
|
+
join_dependency.send(:alias_tracker).aliases[join.left.name.downcase] = 1
|
63
|
+
end
|
55
64
|
else
|
56
65
|
join_dependency = ::ActiveRecord::Associations::JoinDependency.new(relation.klass, association_joins, join_list)
|
57
66
|
join_nodes.each do |join|
|
@@ -62,8 +71,14 @@ module JoinDependency
|
|
62
71
|
join_dependency
|
63
72
|
end
|
64
73
|
|
65
|
-
def
|
66
|
-
ActiveRecord::VERSION::MAJOR
|
74
|
+
def exactly?(major, minor = 0, tiny = 0)
|
75
|
+
ActiveRecord::VERSION::MAJOR == major && ActiveRecord::VERSION::MINOR == minor && ActiveRecord::VERSION::TINY == tiny
|
76
|
+
end
|
77
|
+
|
78
|
+
def at_least?(major, minor = 0, tiny = 0)
|
79
|
+
ActiveRecord::VERSION::MAJOR > major ||
|
80
|
+
(ActiveRecord::VERSION::MAJOR == major && ActiveRecord::VERSION::MINOR >= minor) ||
|
81
|
+
(ActiveRecord::VERSION::MAJOR == major && ActiveRecord::VERSION::MINOR == minor && ActiveRecord::VERSION::TINY == tiny)
|
67
82
|
end
|
68
83
|
end
|
69
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: join_dependency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|