adaptive_alias 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -1
- data/lib/adaptive_alias/patches/base.rb +31 -6
- data/lib/adaptive_alias/version.rb +1 -1
- 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: f2c42a4fb70c22a74c09b64fba9c94dc0b1189a94c3e1ca954161ef20e074460
|
4
|
+
data.tar.gz: 51ae34971dff012f5e691bd8fd79252db0706277e38dcdf43766b7eca1b163aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f30e10e5a9b035b255eeb129673563b56b10b5ee2fbdac22717fc31dd9a815e77bc1f5a5238c04dfe9cff27414e6db8e72f8bf5c1e360f3905dff29e1cd17d7
|
7
|
+
data.tar.gz: 3b1048bc0d4a42ea9f06a4ecfd215a15ae4687f67d1d52b659a64a096151eb40efe987f7ce3b46273ab89013d0739e7ca925db4ced2f3ca4fe4fcc6a2fb7bb54
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
## Change Log
|
2
2
|
|
3
|
-
### [
|
3
|
+
### [v0.2.3](https://github.com/khiav223577/adaptive_alias/compare/v0.2.2...v0.2.3) 2022/08/17
|
4
|
+
- [#17](https://github.com/khiav223577/adaptive_alias/pull/17) [Feature] Support joins (@khiav223577)
|
4
5
|
- [#16](https://github.com/khiav223577/adaptive_alias/pull/16) [Enhance] No need to clone node (@khiav223577)
|
5
6
|
- [#15](https://github.com/khiav223577/adaptive_alias/pull/15) [Test] Add test cases to test calling pluck on same model (@khiav223577)
|
6
7
|
|
@@ -68,6 +68,21 @@ module AdaptiveAlias
|
|
68
68
|
next true
|
69
69
|
end
|
70
70
|
|
71
|
+
fix_arel_attributes = proc do |attr|
|
72
|
+
next if not attr.is_a?(Arel::Attributes::Attribute)
|
73
|
+
next if attr.name != current_column.to_s
|
74
|
+
next if klass.table_name != attr.relation.name
|
75
|
+
|
76
|
+
attr.name = alias_column.to_s
|
77
|
+
end
|
78
|
+
|
79
|
+
fix_arel_nodes = proc do |nodes|
|
80
|
+
each_nodes(nodes) do |node|
|
81
|
+
fix_arel_attributes.call(node.left)
|
82
|
+
fix_arel_attributes.call(node.right)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
71
86
|
@fix_association = proc do |relation, reflection, error|
|
72
87
|
next false if not patch.removable
|
73
88
|
next false if patch.removed
|
@@ -84,12 +99,9 @@ module AdaptiveAlias
|
|
84
99
|
patch.remove!
|
85
100
|
|
86
101
|
if relation
|
87
|
-
relation.
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
node.left.name = alias_column.to_s
|
92
|
-
end
|
102
|
+
joins = relation.arel.source.right # @ctx.source.right << create_join(relation, nil, klass)
|
103
|
+
fix_arel_nodes.call(joins.map{|s| s.right.expr })
|
104
|
+
fix_arel_nodes.call(relation.where_clause.send(:predicates))
|
93
105
|
end
|
94
106
|
|
95
107
|
reflection.clear_association_scope_cache if reflection
|
@@ -116,6 +128,19 @@ module AdaptiveAlias
|
|
116
128
|
def mark_removable
|
117
129
|
@removable = true
|
118
130
|
end
|
131
|
+
|
132
|
+
private
|
133
|
+
|
134
|
+
def each_nodes(nodes, &block)
|
135
|
+
nodes.each do |node|
|
136
|
+
case node
|
137
|
+
when Arel::Nodes::Equality
|
138
|
+
yield(node)
|
139
|
+
when Arel::Nodes::And
|
140
|
+
each_nodes(node.children, &block)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
119
144
|
end
|
120
145
|
end
|
121
146
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adaptive_alias
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khiav reoy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|