(
&self,
uid: &str,
object: &Object,
attributes: &Attributes,
tags: Option<&HashSet<String>>,
)
| 795 | } |
| 796 | |
| 797 | async fn update_object( |
| 798 | &self, |
| 799 | uid: &str, |
| 800 | object: &Object, |
| 801 | attributes: &Attributes, |
| 802 | tags: Option<&HashSet<String>>, |
| 803 | ) -> InterfaceResult<()> { |
| 804 | async fn transact( |
| 805 | tx: &deadpool_postgres::Transaction<'_>, |
| 806 | uid: &str, |
| 807 | object: &Object, |
| 808 | attributes: &Attributes, |
| 809 | tags: Option<&HashSet<String>>, |
| 810 | ) -> DbResult<()> { |
| 811 | let object_json = serde_json::to_string(object).map_err(DbError::from)?; |
| 812 | let attrs_param = Json(attributes); |
| 813 | let wrapping_key_id = object.wrapping_key_uid(); |
| 814 | let stmt = tx |
| 815 | .prepare_cached(get_pgsql_query!("update-object-with-object")) |
| 816 | .await |
| 817 | .map_err(DbError::from)?; |
| 818 | tx.execute(&stmt, &[&object_json, &attrs_param, &wrapping_key_id, &uid]) |
| 819 | .await |
| 820 | .map_err(DbError::from)?; |
| 821 | if let Some(tags) = tags { |
| 822 | let delete_stmt = tx |
| 823 | .prepare_cached(get_pgsql_query!("delete-tags")) |
| 824 | .await |
| 825 | .map_err(DbError::from)?; |
| 826 | tx.execute(&delete_stmt, &[&uid]) |
| 827 | .await |
| 828 | .map_err(DbError::from)?; |
| 829 | let insert_stmt = tx |
| 830 | .prepare_cached(get_pgsql_query!("insert-tags")) |
| 831 | .await |
| 832 | .map_err(DbError::from)?; |
| 833 | for tag in tags { |
| 834 | tx.execute(&insert_stmt, &[&uid, tag]) |
| 835 | .await |
| 836 | .map_err(DbError::from)?; |
| 837 | } |
| 838 | } |
| 839 | Ok(()) |
| 840 | } |
| 841 | |
| 842 | pg_retry_tx!(self.pool, |tx| { |
| 843 | transact(&tx, uid, object, attributes, tags).await |
| 844 | }) |
| 845 | } |
| 846 | |
| 847 | async fn update_state(&self, uid: &str, state: State) -> InterfaceResult<()> { |
| 848 | pg_retry!(self.pool, |client| { |
nothing calls this directly
no outgoing calls
no test coverage detected