diff --git a/.sqlx/query-7438ddaf9ed9fab7ba4cb1b9c79ff541fa2e63a629cad4f8e9692a50a4e5e03c.json b/.sqlx/query-a8443c8307a099fbfa3e04232fdc7719c28dc5acac088686e86980544fe4bbc9.json similarity index 62% rename from .sqlx/query-7438ddaf9ed9fab7ba4cb1b9c79ff541fa2e63a629cad4f8e9692a50a4e5e03c.json rename to .sqlx/query-a8443c8307a099fbfa3e04232fdc7719c28dc5acac088686e86980544fe4bbc9.json index e2d55ff09..9fd3e6961 100644 --- a/.sqlx/query-7438ddaf9ed9fab7ba4cb1b9c79ff541fa2e63a629cad4f8e9692a50a4e5e03c.json +++ b/.sqlx/query-a8443c8307a099fbfa3e04232fdc7719c28dc5acac088686e86980544fe4bbc9.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT *\n FROM public.af_user_profile_view WHERE uuid = $1\n ", + "query": "\n WITH af_user_row AS (\n SELECT * FROM af_user WHERE uuid = $1\n )\n SELECT\n af_user_row.uid,\n af_user_row.uuid,\n af_user_row.email,\n af_user_row.password,\n af_user_row.name,\n af_user_row.metadata,\n af_user_row.encryption_sign,\n af_user_row.deleted_at,\n af_user_row.updated_at,\n af_user_row.created_at,\n (SELECT workspace_id\n FROM af_workspace_member\n WHERE uid = af_user_row.uid\n ORDER BY updated_at DESC\n LIMIT 1) as latest_workspace_id\n FROM af_user_row\n ", "describe": { "columns": [ { @@ -65,18 +65,18 @@ ] }, "nullable": [ + false, + false, + false, + false, + false, true, true, true, true, true, - true, - true, - true, - true, - true, - true + null ] }, - "hash": "7438ddaf9ed9fab7ba4cb1b9c79ff541fa2e63a629cad4f8e9692a50a4e5e03c" + "hash": "a8443c8307a099fbfa3e04232fdc7719c28dc5acac088686e86980544fe4bbc9" } diff --git a/libs/database/src/workspace.rs b/libs/database/src/workspace.rs index 7e4ec3aec..2b638f4f8 100644 --- a/libs/database/src/workspace.rs +++ b/libs/database/src/workspace.rs @@ -584,8 +584,26 @@ pub async fn select_user_profile<'a, E: Executor<'a, Database = Postgres>>( let user_profile = sqlx::query_as!( AFUserProfileRow, r#" - SELECT * - FROM public.af_user_profile_view WHERE uuid = $1 + WITH af_user_row AS ( + SELECT * FROM af_user WHERE uuid = $1 + ) + SELECT + af_user_row.uid, + af_user_row.uuid, + af_user_row.email, + af_user_row.password, + af_user_row.name, + af_user_row.metadata, + af_user_row.encryption_sign, + af_user_row.deleted_at, + af_user_row.updated_at, + af_user_row.created_at, + (SELECT workspace_id + FROM af_workspace_member + WHERE uid = af_user_row.uid + ORDER BY updated_at DESC + LIMIT 1) as latest_workspace_id + FROM af_user_row "#, user_uuid )