(
&self,
object_type: &str,
id: &str,
name: &str,
scope: &str,
payload: &[u8],
labels: Option<&str>,
)
| 262 | } |
| 263 | |
| 264 | pub async fn put_scoped( |
| 265 | &self, |
| 266 | object_type: &str, |
| 267 | id: &str, |
| 268 | name: &str, |
| 269 | scope: &str, |
| 270 | payload: &[u8], |
| 271 | labels: Option<&str>, |
| 272 | ) -> PersistenceResult<()> { |
| 273 | let now_ms = current_time_ms(); |
| 274 | |
| 275 | sqlx::query( |
| 276 | r#" |
| 277 | INSERT INTO "objects" ("object_type", "id", "name", "scope", "payload", "created_at_ms", "updated_at_ms", "labels", "resource_version") |
| 278 | VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?6, ?7, 1) |
| 279 | ON CONFLICT ("object_type", "name") WHERE "name" IS NOT NULL DO UPDATE SET |
| 280 | "scope" = excluded."scope", |
| 281 | "payload" = excluded."payload", |
| 282 | "updated_at_ms" = excluded."updated_at_ms", |
| 283 | "labels" = excluded."labels", |
| 284 | "resource_version" = "objects"."resource_version" + 1 |
| 285 | "#, |
| 286 | ) |
| 287 | .bind(object_type) |
| 288 | .bind(id) |
| 289 | .bind(name) |
| 290 | .bind(scope) |
| 291 | .bind(payload) |
| 292 | .bind(now_ms) |
| 293 | .bind(labels.unwrap_or("{}")) |
| 294 | .execute(&self.pool) |
| 295 | .await |
| 296 | .map_err(|e| map_db_error(&e))?; |
| 297 | Ok(()) |
| 298 | } |
| 299 | |
| 300 | pub async fn get( |
| 301 | &self, |
nothing calls this directly
no test coverage detected