praxis 2.0.pre.3 → 2.0.pre.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/praxis/mapper/selector_generator.rb +11 -6
- data/lib/praxis/version.rb +1 -1
- data/spec/praxis/mapper/selector_generator_spec.rb +32 -0
- 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: fa827ff7e042719b8976def88a05ab420fa05eb5
|
4
|
+
data.tar.gz: a3c09e65e43ea6d5ef508ca9be649552b271b305
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9055b2bb74579f7b0bfb6b2823df6b03dc863e30945314aa7d2251326ad1e4c7bf9a2213b24251ca8334e3e00bca5371b4fbc7d7199e7829ca4f625c9f1f0a97
|
7
|
+
data.tar.gz: e458dcf8e0d69e5df81ca9a2a1bc62250891ac788f7cfd2dbc9e08a76193bcf797d099799f83cfbdc0c2010e3fe3b23bef917efc036a80f95029f0437904f847
|
@@ -19,9 +19,10 @@ module Praxis::Mapper
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def map_property(name, fields)
|
22
|
+
praxis_compat_model = resource.model && resource.model.respond_to?(:_praxis_associations)
|
22
23
|
if resource.properties.key?(name)
|
23
24
|
add_property(name, fields)
|
24
|
-
elsif resource.model._praxis_associations.key?(name)
|
25
|
+
elsif praxis_compat_model && resource.model._praxis_associations.key?(name)
|
25
26
|
add_association(name, fields)
|
26
27
|
else
|
27
28
|
add_select(name)
|
@@ -68,13 +69,18 @@ module Praxis::Mapper
|
|
68
69
|
def add_property(name, fields)
|
69
70
|
dependencies = resource.properties[name][:dependencies]
|
70
71
|
# Always add the underlying association if we're overriding the name...
|
71
|
-
|
72
|
+
praxis_compat_model = resource.model && resource.model.respond_to?(:_praxis_associations)
|
73
|
+
if praxis_compat_model && resource.model._praxis_associations.key?(name)
|
74
|
+
add_association(name, fields)
|
75
|
+
end
|
72
76
|
if dependencies
|
73
77
|
dependencies.each do |dependency|
|
74
78
|
# To detect recursion, let's allow mapping depending fields to the same name of the property
|
75
79
|
# but properly detecting if it's a real association...in which case we've already added it above
|
76
|
-
if dependency == name
|
77
|
-
|
80
|
+
if dependency == name
|
81
|
+
unless praxis_compat_model && resource.model._praxis_associations.key?(name)
|
82
|
+
add_select(name)
|
83
|
+
end
|
78
84
|
else
|
79
85
|
apply_dependency(dependency)
|
80
86
|
end
|
@@ -112,12 +118,11 @@ module Praxis::Mapper
|
|
112
118
|
existing.add_select(col_name)
|
113
119
|
end
|
114
120
|
node.tracks.each do |name, n|
|
115
|
-
existing.
|
121
|
+
existing.merge_track(name, n)
|
116
122
|
end
|
117
123
|
else
|
118
124
|
self.tracks[track_name] = node
|
119
125
|
end
|
120
|
-
|
121
126
|
end
|
122
127
|
|
123
128
|
def dump
|
data/lib/praxis/version.rb
CHANGED
@@ -181,6 +181,38 @@ describe Praxis::Mapper::SelectorGenerator do
|
|
181
181
|
end
|
182
182
|
it_behaves_like 'a proper selector'
|
183
183
|
end
|
184
|
+
|
185
|
+
context 'merging multiple tracks with the same name within a node' do
|
186
|
+
let(:fields) do
|
187
|
+
{ # Both everything_from_parent and parent will track the underlying 'parent' assoc
|
188
|
+
# ...and the final respective fields and tracks will need to be merged together.
|
189
|
+
# columns will be merged by just *, and tracks will merge true with simple children
|
190
|
+
everything_from_parent: true,
|
191
|
+
parent: {
|
192
|
+
simple_children: true
|
193
|
+
}
|
194
|
+
}
|
195
|
+
end
|
196
|
+
let(:selectors) do
|
197
|
+
{
|
198
|
+
model: SimpleModel,
|
199
|
+
columns: [:parent_id, :added_column],
|
200
|
+
tracks: {
|
201
|
+
parent: {
|
202
|
+
model: ParentModel,
|
203
|
+
columns: [:*],
|
204
|
+
tracks: {
|
205
|
+
simple_children: {
|
206
|
+
model: SimpleModel,
|
207
|
+
columns: [:parent_id]
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
}
|
212
|
+
}
|
213
|
+
end
|
214
|
+
it_behaves_like 'a proper selector'
|
215
|
+
end
|
184
216
|
end
|
185
217
|
|
186
218
|
context 'string associations' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: praxis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.pre.
|
4
|
+
version: 2.0.pre.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep M. Blanquer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|