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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c797f44180ed02342106236cb97af580057251b70187f0f73bd764f95ca93a0
4
- data.tar.gz: 1fa0e2d26beafa4a52427c7ee004a37887ee436cdc647b65b16a552684c7e6b9
3
+ metadata.gz: e8125aeb13e491c0d44821cca3c243754167473029057f2603455f7c8794a43b
4
+ data.tar.gz: 28f39b6a84d9cdb20a7f2a57729f570f2b0aa56a84d0a7864ad8a15a108e57b7
5
5
  SHA512:
6
- metadata.gz: 4f69ffa1250bf724a7edcce1137d95987c9004d2001edf3c2416106369f673899e549741550f5b4c5567a1ea78be3947f7ce712282a12ac27c181d73824b7ef5
7
- data.tar.gz: 76fa9c6e7d062e7d769aefa33447ec054ccbe503aac2113c0033f2911457d70ddb488d270f77ec834a13ec3af03ad1ff754d6e0a2a943fda8b5dbbdedb4e3ec9
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
- resolve_all = false
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
@@ -1,3 +1,3 @@
1
1
  module Solis
2
- VERSION = "0.119.0"
2
+ VERSION = "0.121.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.119.0
4
+ version: 0.121.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Celik