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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dda55b018b09a647fc40f1a7b59a24f1cc81c00a3c2349085848644a27001ab
4
- data.tar.gz: 6ca894d3ee02c398d48089de53880843086e2de4fd44eb9b6de73a6fb666d4d9
3
+ metadata.gz: d8cffecfd290bbbcbdcc598997b537acd52ff9f2afd2d2c3ba1cc372465ab956
4
+ data.tar.gz: fa9d90a857113b7e93ea2f3ce2e6eead3f777ee50b8541b74aa29f120e304780
5
5
  SHA512:
6
- metadata.gz: 5f2051ce47d99d57693d7e2f216cc22c7914b652909b6d73841db5aed81d910d179e5e3951b88a269ddbcdf59b0d5f2ce07920a652e5ef461dcbdd586074dba8
7
- data.tar.gz: af28d209b1c910f639e1d1bad30c9d540d15bfbc7c625669d4b8bdde02abfeca63add4b5a2a51c2345633042586a938019b8dce88c840fe0c50af1e4ab113a21
6
+ metadata.gz: e90bab34d75b8a8ca8b6d444b9d4bf1dea827bcbb5d2ef7ba4ad858a5f77d8520d4f06c576eec2702e540bd5806fb1d74fbb96f40e50ec5144cb89cdd1d30d74
7
+ data.tar.gz: 32413e65f2adb1a64d716a822ce849ee3f02c47e7272be2f1ca22315e403a725d994dd7f862d4c2806ab9a1d6f7c11c7377cd0cef19962b3e9de3bfe3ee53f3a
data/.travis.yml CHANGED
@@ -11,5 +11,6 @@ env:
11
11
  - AR=5.0.6
12
12
  - AR=5.1.5
13
13
  - AR=5.2.0.rc1
14
+ - AR=5.2.1
14
15
  - AR=latest
15
16
 
@@ -1,3 +1,3 @@
1
1
  module JoinDependency
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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, 2)
42
- join_nodes + relation.send(:convert_join_strings_to_ast, string_joins)
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 at_least?(5, 2)
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 at_least?(major, minor = 0)
66
- ActiveRecord::VERSION::MAJOR >= major && ActiveRecord::VERSION::MINOR >= minor
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.2
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-05-15 00:00:00.000000000 Z
11
+ date: 2018-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord