(
&self,
object_type: &str,
id: &str,
name: &str,
payload: &[u8],
labels: Option<&str>,
)
| 81 | } |
| 82 | |
| 83 | pub async fn put( |
| 84 | &self, |
| 85 | object_type: &str, |
| 86 | id: &str, |
| 87 | name: &str, |
| 88 | payload: &[u8], |
| 89 | labels: Option<&str>, |
| 90 | ) -> PersistenceResult<()> { |
| 91 | let now_ms = current_time_ms(); |
| 92 | |
| 93 | sqlx::query( |
| 94 | r#" |
| 95 | INSERT INTO "objects" ("object_type", "id", "name", "payload", "created_at_ms", "updated_at_ms", "labels") |
| 96 | VALUES (?1, ?2, ?3, ?4, ?5, ?5, ?6) |
| 97 | ON CONFLICT ("object_type", "name") WHERE "name" IS NOT NULL DO UPDATE SET |
| 98 | "payload" = excluded."payload", |
| 99 | "updated_at_ms" = excluded."updated_at_ms", |
| 100 | "labels" = excluded."labels" |
| 101 | "#, |
| 102 | ) |
| 103 | .bind(object_type) |
| 104 | .bind(id) |
| 105 | .bind(name) |
| 106 | .bind(payload) |
| 107 | .bind(now_ms) |
| 108 | .bind(labels.unwrap_or("{}")) |
| 109 | .execute(&self.pool) |
| 110 | .await |
| 111 | .map_err(|e| map_db_error(&e))?; |
| 112 | Ok(()) |
| 113 | } |
| 114 | |
| 115 | pub async fn put_if( |
| 116 | &self, |
nothing calls this directly
no test coverage detected