/// Applies an update operation to an existing entity
Applies an update operation to an existing entity
Applies an update operation to an existing entity
fn apply_update_operation(
        &self,
        conn: &e::Connection,
        key: EntityKey,
        data: Entity,
        guard: Option<EntityFilter>,
        event_source: EventSource,
    ) -> Result<(), StoreError> {
        self.check_interface_entity_uniqueness(conn, &key)?;
        let json: serde_json::Value = serde_json::to_value(&data).map_err(|e| {
            format_err!(
                "Failed to update entity ({}, {}, {}) as updating it would break it: {}",
                key.subgraph_id,
                key.entity_type,
                key.entity_id,
                e
            )
        })?;
        // Update the entity in Postgres
        match conn.update(&key, &json, guard, event_source)? {
            0 => Err(TransactionAbortError::AbortUnless {
                expected_entity_ids: vec![key.entity_id.clone()],
                actual_entity_ids: vec![],
                description: "update did not change any rows".to_owned(),
            }
            .into()),
            1 => Ok(()),
            res => Err(TransactionAbortError::AbortUnless {
                expected_entity_ids: vec![key.entity_id.clone()],
                actual_entity_ids: vec![],
                description: format!("update changed {} rows instead of just one", res),
            }
            .into()),
        }
    }
fn apply_update_operation ( & self , conn : & e :: Connection , key : EntityKey , data : Entity , guard : Option < EntityFilter > , event_source : EventSource , ) -> Result < ( ) , StoreError > { self . check_interface_entity_uniqueness ( conn , & key ) ? ; let json : serde_json :: Value = serde_json :: to_value ( & data ) . map_err ( | e | { format_err ! ( " " key subgraph_id key entity_type key entity_id e ) } ) ? ; // Update the entity in Postgres match conn . update ( & key , & json , guard , event_source ) ? { 0 => Err ( TransactionAbortError :: AbortUnless { expected_entity_ids : vec ! [ key entity_id clone ( ) ] , actual_entity_ids : vec ! [ ] , description : " " . to_owned ( ) , } . into ( ) ) , 1 => Ok ( ( ) ) , res => Err ( TransactionAbortError :: AbortUnless { expected_entity_ids : vec ! [ key entity_id clone ( ) ] , actual_entity_ids : vec ! [ ] , description : format ! ( " " res ) , } . into ( ) ) , } }
Applies an update operation to an existing entity
Applies an update operation to an existing entity
&self
conn
&e::Connection
key
EntityKey
data
Entity
guard
Option<EntityFilter>
event_source
EventSource