Fiks workspace JSONB type-mismatch: metadata leses som serde_json::Value
WorkspaceRow.metadata var String, men PG-kolonnen er JSONB. Første opprettelse fungerte (inserter Value), men oppslag feilet ved andre besøk. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6370b02cc7
commit
09f69d1fdb
1 changed files with 2 additions and 4 deletions
|
|
@ -28,7 +28,7 @@ pub struct WorkspaceResponse {
|
||||||
struct WorkspaceRow {
|
struct WorkspaceRow {
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
title: String,
|
title: String,
|
||||||
metadata: String,
|
metadata: serde_json::Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GET /my/workspace — finn eller opprett brukerens personlige workspace.
|
/// GET /my/workspace — finn eller opprett brukerens personlige workspace.
|
||||||
|
|
@ -57,12 +57,10 @@ pub async fn my_workspace(
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if let Some(row) = existing {
|
if let Some(row) = existing {
|
||||||
let metadata: serde_json::Value =
|
|
||||||
serde_json::from_str(&row.metadata).unwrap_or(serde_json::json!({}));
|
|
||||||
return Ok(Json(WorkspaceResponse {
|
return Ok(Json(WorkspaceResponse {
|
||||||
node_id: row.id,
|
node_id: row.id,
|
||||||
title: row.title,
|
title: row.title,
|
||||||
metadata,
|
metadata: row.metadata,
|
||||||
created: false,
|
created: false,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue