solis 0.119.0 → 0.121.0
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/solis/model.rb +25 -1
- data/lib/solis/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8125aeb13e491c0d44821cca3c243754167473029057f2603455f7c8794a43b
|
|
4
|
+
data.tar.gz: 28f39b6a84d9cdb20a7f2a57729f570f2b0aa56a84d0a7864ad8a15a108e57b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66ee13e892ee4bcfd1d2d8c762a6dc9f014a1cee03339e3440bdad93fc8197550ef9c609993326193a611b8ef86d48d1c17c2d90e7d2b5d46bfa396f08b3015e
|
|
7
|
+
data.tar.gz: 351b8b1a0cb8939398f77ae05df71188dd844adb84424cb5a1abe453261e30a86c1d90f3293d3b1598d2acbb0f8052197fd0d5c01559fa257ebbf80f5ee4cdb3
|
data/lib/solis/model.rb
CHANGED
|
@@ -669,6 +669,15 @@ values ?s {<#{self.graph_id}>}
|
|
|
669
669
|
obj.class.ancestors.include?(Solis::Model)
|
|
670
670
|
end
|
|
671
671
|
|
|
672
|
+
# True when only the entity's id is populated — an id-only stub, e.g. an embedded
|
|
673
|
+
# relation materialised by Query#graph_to_object as Model.new(id:).
|
|
674
|
+
def shallow_stub?(entity)
|
|
675
|
+
return false unless solis_model?(entity)
|
|
676
|
+
entity.class.metadata[:attributes].each_key.none? do |attr|
|
|
677
|
+
attr.to_s != 'id' && !entity.instance_variable_get("@#{attr}").nil?
|
|
678
|
+
end
|
|
679
|
+
end
|
|
680
|
+
|
|
672
681
|
# Helper method to check if an entity is readonly (code table)
|
|
673
682
|
def readonly_entity?(entity, readonly_list = nil)
|
|
674
683
|
readonly_list ||= (Solis::Options.instance.get[:embedded_readonly] || []).map(&:to_s)
|
|
@@ -797,7 +806,10 @@ values ?s {<#{self.graph_id}>}
|
|
|
797
806
|
if original_klass.nil?
|
|
798
807
|
original_klass = klass
|
|
799
808
|
else
|
|
800
|
-
|
|
809
|
+
# A store-fetched original carries id-only stub children, so its subgraph is
|
|
810
|
+
# not re-resolved. In the create path (skip_store_fetch) known_entities is
|
|
811
|
+
# pre-populated with full in-memory entities whose children must still be built.
|
|
812
|
+
resolve_all = false unless skip_store_fetch
|
|
801
813
|
klass.instance_variables.map { |m| m.to_s.gsub(/^@/, '') }
|
|
802
814
|
.select { |s| !["model_name", "model_plural_name"].include?(s) }.each do |attribute|
|
|
803
815
|
data = klass.instance_variable_get("@#{attribute}")
|
|
@@ -821,6 +833,18 @@ values ?s {<#{self.graph_id}>}
|
|
|
821
833
|
end
|
|
822
834
|
|
|
823
835
|
def make_graph(graph, hierarchy, id, klass, klass_metadata, resolve_all, known_entities = {}, skip_store_fetch: false)
|
|
836
|
+
# klass may arrive as an id-only stub (embedded relation from Query#graph_to_object,
|
|
837
|
+
# or passed via prefetched_original). Resolve it to the full stored entity once so
|
|
838
|
+
# every attribute is emitted into the graph.
|
|
839
|
+
if !skip_store_fetch && shallow_stub?(klass)
|
|
840
|
+
uuid = id.value.split('/').last
|
|
841
|
+
fetched = klass.query.filter({ filters: { id: [uuid] } }).find_all { |f| f.id == uuid }.first
|
|
842
|
+
unless fetched.nil?
|
|
843
|
+
klass = fetched
|
|
844
|
+
known_entities[uuid] = fetched
|
|
845
|
+
end
|
|
846
|
+
end
|
|
847
|
+
|
|
824
848
|
klass_metadata[:attributes].each do |attribute, metadata|
|
|
825
849
|
data = klass.instance_variable_get("@#{attribute}")
|
|
826
850
|
|
data/lib/solis/version.rb
CHANGED