MCPcopy Create free account
hub / github.com/hashintel/hash / hydrate_from_postgres

Method hydrate_from_postgres

libs/@local/hashql/eval/src/orchestrator/partial.rs:625–853  ·  view source on GitHub ↗
(
        &mut self,
        env: &Environment<'heap>,
        decoder: &Decoder<'_, 'heap, A>,
        path: EntityPath,
        r#type: TypeId,
        column: Indexed<ColumnDescriptor>,
        row

Source from the content-addressed store, hash-verified

623
624 #[expect(clippy::too_many_lines)]
625 fn hydrate_from_postgres(
626 &mut self,
627 env: &Environment<'heap>,
628 decoder: &Decoder<'_, 'heap, A>,
629 path: EntityPath,
630 r#type: TypeId,
631 column: Indexed<ColumnDescriptor>,
632 row: &Row,
633 ) -> Result<(), BridgeError<'heap>>
634 where
635 A: Clone,
636 {
637 let row_hydration_error = |source| BridgeError::RowHydration { column, source };
638
639 match path {
640 EntityPath::Properties => {
641 let value: serde_json::Value =
642 row.try_get(column.index).map_err(row_hydration_error)?;
643 let value = decoder.try_decode(r#type, (&value).into(), column)?;
644 self.properties.set(value);
645 }
646 EntityPath::Vectors => unreachable!(
647 "entity vectors should never reach postgres compilation; the placement pass \
648 should have rejected this"
649 ),
650 EntityPath::RecordId => {
651 let value: serde_json::Value =
652 row.try_get(column.index).map_err(row_hydration_error)?;
653
654 let entity_id = &value["entity_id"];
655 let edition_id = &value["edition_id"];
656
657 self.hydrate_entity_id(env, decoder, column, entity_id)?;
658 self.hydrate_edition_id(env, decoder, column, edition_id)?;
659 }
660 EntityPath::EntityId => {
661 let value: serde_json::Value =
662 row.try_get(column.index).map_err(row_hydration_error)?;
663
664 self.hydrate_entity_id(env, decoder, column, &value)?;
665 }
666 EntityPath::WebId => {
667 let value: Uuid = row.try_get(column.index).map_err(row_hydration_error)?;
668 self.hydrate_web_id(
669 env,
670 decoder,
671 column,
672 JsonValueRef::String(&value.hyphenated().to_string()),
673 )?;
674 }
675 EntityPath::EntityUuid => {
676 let value: Uuid = row.try_get(column.index).map_err(row_hydration_error)?;
677 self.hydrate_entity_uuid(
678 env,
679 decoder,
680 column,
681 JsonValueRef::String(&value.hyphenated().to_string()),
682 )?;

Callers 1

postgres_hydrate_inMethod · 0.80

Calls 15

StringClass · 0.85
OkInterface · 0.85
map_errMethod · 0.80
try_decodeMethod · 0.80
hydrate_entity_idMethod · 0.80
hydrate_edition_idMethod · 0.80
hydrate_web_idMethod · 0.80
hydrate_entity_uuidMethod · 0.80
hydrate_draft_idMethod · 0.80
hydrate_decision_timeMethod · 0.80
try_nullMethod · 0.80

Tested by

no test coverage detected