diff --git a/clippy.toml b/clippy.toml index fe289d379..3aff60816 100644 --- a/clippy.toml +++ b/clippy.toml @@ -6,3 +6,9 @@ allow-dbg-in-tests = true # The project's name is a word in prose, not code. `..` keeps Clippy's defaults. doc-valid-idents = ["SourceOrigin", ".."] + +# SQL is compiled against the schema with the checked macros, which `just db +# prepare` caches. A statement built at run time takes an `#[expect]` saying why. +disallowed-methods = [ + { path = "sqlx::query", reason = "use the checked `sqlx::query!`; a statement built at run time needs an `#[expect]`" }, +] diff --git a/crates/database/.sqlx/query-001d3aebd8987f77d93448470194a42db291b2a964a0ada162c01bc2d908df38.json b/crates/database/.sqlx/query-001d3aebd8987f77d93448470194a42db291b2a964a0ada162c01bc2d908df38.json new file mode 100644 index 000000000..2b747af4d --- /dev/null +++ b/crates/database/.sqlx/query-001d3aebd8987f77d93448470194a42db291b2a964a0ada162c01bc2d908df38.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO sessions (\n id, user_id, authentication_methods, authenticated_at, expires_at, last_seen_at\n ) VALUES ($1, $2, '[]', now() - interval '2 hours', now() - interval '1 hour',\n now() - interval '2 hours')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "001d3aebd8987f77d93448470194a42db291b2a964a0ada162c01bc2d908df38" +} diff --git a/crates/database/.sqlx/query-0920716a061cb8f2ea998f118eeec650e2270f3d8b0237eeeaceb59febfb4562.json b/crates/database/.sqlx/query-0920716a061cb8f2ea998f118eeec650e2270f3d8b0237eeeaceb59febfb4562.json new file mode 100644 index 000000000..fe25f82cf --- /dev/null +++ b/crates/database/.sqlx/query-0920716a061cb8f2ea998f118eeec650e2270f3d8b0237eeeaceb59febfb4562.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO passkey_credentials(id,credential_id,user_id,credential,friendly_name)\n VALUES($1,$2,$3,'{}','Lock test')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Bytea", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "0920716a061cb8f2ea998f118eeec650e2270f3d8b0237eeeaceb59febfb4562" +} diff --git a/crates/database/.sqlx/query-0f35eeac8f28474ccdaf3664e55e2fe9a7372bd727c43f3935e8c8d228e17219.json b/crates/database/.sqlx/query-0f35eeac8f28474ccdaf3664e55e2fe9a7372bd727c43f3935e8c8d228e17219.json new file mode 100644 index 000000000..0a3ee3813 --- /dev/null +++ b/crates/database/.sqlx/query-0f35eeac8f28474ccdaf3664e55e2fe9a7372bd727c43f3935e8c8d228e17219.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE user_emails SET verified_at=now(),is_primary=true WHERE id=$1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "0f35eeac8f28474ccdaf3664e55e2fe9a7372bd727c43f3935e8c8d228e17219" +} diff --git a/crates/database/.sqlx/query-10eabad779493d0d84aea006d2832948bc6cec13e701475faa285a1cca81667c.json b/crates/database/.sqlx/query-10eabad779493d0d84aea006d2832948bc6cec13e701475faa285a1cca81667c.json new file mode 100644 index 000000000..7cd1afa6b --- /dev/null +++ b/crates/database/.sqlx/query-10eabad779493d0d84aea006d2832948bc6cec13e701475faa285a1cca81667c.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO authorization_codes (\n id, secret_digest, client_id, user_id, session_id, redirect_uri,\n pkce_challenge, scopes, audience, expires_at, authentication, digest_key\n ) VALUES ($1, $2, $3, $4, $5, $6, 'challenge', '[\"openid\"]', 'test',\n now() + interval '1 minute', $7, 'test')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Bytea", + "Text", + "Uuid", + "Uuid", + "Text", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "10eabad779493d0d84aea006d2832948bc6cec13e701475faa285a1cca81667c" +} diff --git a/crates/database/.sqlx/query-11bd90418a1000de688748966e9008e4f70ad3cbd2563da0544a0135fda5fee2.json b/crates/database/.sqlx/query-11bd90418a1000de688748966e9008e4f70ad3cbd2563da0544a0135fda5fee2.json new file mode 100644 index 000000000..e2da3ccb0 --- /dev/null +++ b/crates/database/.sqlx/query-11bd90418a1000de688748966e9008e4f70ad3cbd2563da0544a0135fda5fee2.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "SET CONSTRAINTS ALL IMMEDIATE", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "11bd90418a1000de688748966e9008e4f70ad3cbd2563da0544a0135fda5fee2" +} diff --git a/crates/database/.sqlx/query-15b28682406fbe0e952e26f948efce63c3a32ea69d24383bfef430c37edb38b2.json b/crates/database/.sqlx/query-15b28682406fbe0e952e26f948efce63c3a32ea69d24383bfef430c37edb38b2.json new file mode 100644 index 000000000..7caf873d1 --- /dev/null +++ b/crates/database/.sqlx/query-15b28682406fbe0e952e26f948efce63c3a32ea69d24383bfef430c37edb38b2.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH account AS (INSERT INTO users(id,display_name) VALUES($1,'Decode test'))\n INSERT INTO handles(handle,user_id) VALUES($2,$1)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "15b28682406fbe0e952e26f948efce63c3a32ea69d24383bfef430c37edb38b2" +} diff --git a/crates/database/.sqlx/query-18c74021f6fbdb65bc41f2c5c6107f483b98c9d5832dd8a1cc92bc2e49da3eac.json b/crates/database/.sqlx/query-18c74021f6fbdb65bc41f2c5c6107f483b98c9d5832dd8a1cc92bc2e49da3eac.json new file mode 100644 index 000000000..b201b1968 --- /dev/null +++ b/crates/database/.sqlx/query-18c74021f6fbdb65bc41f2c5c6107f483b98c9d5832dd8a1cc92bc2e49da3eac.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE sessions SET revoked_at=now() WHERE id=$1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "18c74021f6fbdb65bc41f2c5c6107f483b98c9d5832dd8a1cc92bc2e49da3eac" +} diff --git a/crates/database/.sqlx/query-1c2817dc06c00a1809d70955e1f993f6ddc3488fbaff5bd7c8aa78395d5d1c3d.json b/crates/database/.sqlx/query-1c2817dc06c00a1809d70955e1f993f6ddc3488fbaff5bd7c8aa78395d5d1c3d.json new file mode 100644 index 000000000..bee2e29c3 --- /dev/null +++ b/crates/database/.sqlx/query-1c2817dc06c00a1809d70955e1f993f6ddc3488fbaff5bd7c8aa78395d5d1c3d.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE refresh_tokens SET consumed_at=now() WHERE id=$1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "1c2817dc06c00a1809d70955e1f993f6ddc3488fbaff5bd7c8aa78395d5d1c3d" +} diff --git a/crates/database/.sqlx/query-1cf290c2d96b29b8007a681758bd9521a6d3758b3e482b5fb67df85515a31c62.json b/crates/database/.sqlx/query-1cf290c2d96b29b8007a681758bd9521a6d3758b3e482b5fb67df85515a31c62.json new file mode 100644 index 000000000..09bf42000 --- /dev/null +++ b/crates/database/.sqlx/query-1cf290c2d96b29b8007a681758bd9521a6d3758b3e482b5fb67df85515a31c62.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM user_emails WHERE id=$1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "1cf290c2d96b29b8007a681758bd9521a6d3758b3e482b5fb67df85515a31c62" +} diff --git a/crates/database/.sqlx/query-26526d887f0b6ed3c86d95238517e2ea6fcbafde2a86255a1ad2c4ceb7724f99.json b/crates/database/.sqlx/query-26526d887f0b6ed3c86d95238517e2ea6fcbafde2a86255a1ad2c4ceb7724f99.json new file mode 100644 index 000000000..badeaceee --- /dev/null +++ b/crates/database/.sqlx/query-26526d887f0b6ed3c86d95238517e2ea6fcbafde2a86255a1ad2c4ceb7724f99.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO user_emails (id, user_id, normalized_email, verified_at)\n VALUES ($1, $2, $3, now())", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "26526d887f0b6ed3c86d95238517e2ea6fcbafde2a86255a1ad2c4ceb7724f99" +} diff --git a/crates/database/.sqlx/query-26b847c630f939f18f228f4718866ada027f9315572362532753a1f8075d1c6a.json b/crates/database/.sqlx/query-26b847c630f939f18f228f4718866ada027f9315572362532753a1f8075d1c6a.json new file mode 100644 index 000000000..f32d3c326 --- /dev/null +++ b/crates/database/.sqlx/query-26b847c630f939f18f228f4718866ada027f9315572362532753a1f8075d1c6a.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH account AS (\n INSERT INTO users (id, display_name) VALUES ($1, 'Purge')\n ), browser AS (\n INSERT INTO sessions (\n id, user_id, authentication_methods, authenticated_at, expires_at, last_seen_at\n ) VALUES ($2, $1, '[]', now(), now() + interval '30 days', now())\n ), registration AS (\n INSERT INTO oidc_clients (id, display_name, allowed_scopes, allowed_audiences)\n VALUES ($5, 'Purge', '[]', '[]')\n ), redeemed AS (\n INSERT INTO authorization_codes (\n id, secret_digest, client_id, user_id, session_id, redirect_uri,\n pkce_challenge, scopes, audience, expires_at, consumed_at, authentication,\n digest_key\n ) VALUES ($3, convert_to($3::uuid::text, 'UTF8'), $5, $1, $2, 'https://client.example',\n 'challenge', '[]', 'test', now() - interval '2 days', now() - interval '2 days', '{}',\n 'test')\n )\n INSERT INTO refresh_token_families (\n id, user_id, client_id, session_id, authorization_code_id, audience, scopes,\n authentication\n ) VALUES ($4, $1, $5, $2, $3, 'test', '[]', '{}')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Uuid", + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "26b847c630f939f18f228f4718866ada027f9315572362532753a1f8075d1c6a" +} diff --git a/crates/database/.sqlx/query-27cdde51b9fe970ccfe9f375821f799de1a46dff626397bb8d8684e6654e6fd6.json b/crates/database/.sqlx/query-27cdde51b9fe970ccfe9f375821f799de1a46dff626397bb8d8684e6654e6fd6.json new file mode 100644 index 000000000..44a8b3989 --- /dev/null +++ b/crates/database/.sqlx/query-27cdde51b9fe970ccfe9f375821f799de1a46dff626397bb8d8684e6654e6fd6.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM event_personal_data p USING domain_events e\n WHERE p.event_id = e.id AND e.subject_user_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "27cdde51b9fe970ccfe9f375821f799de1a46dff626397bb8d8684e6654e6fd6" +} diff --git a/crates/database/.sqlx/query-32a4986d96c0bd7708731bf07412fc7a37d10177e9443a29ee8ef7545388ede6.json b/crates/database/.sqlx/query-32a4986d96c0bd7708731bf07412fc7a37d10177e9443a29ee8ef7545388ede6.json new file mode 100644 index 000000000..5ec09a713 --- /dev/null +++ b/crates/database/.sqlx/query-32a4986d96c0bd7708731bf07412fc7a37d10177e9443a29ee8ef7545388ede6.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE users SET status = 'disabled' WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "32a4986d96c0bd7708731bf07412fc7a37d10177e9443a29ee8ef7545388ede6" +} diff --git a/crates/database/.sqlx/query-3d2dfd1a2638591ec261e06f26c807dbf13d2f8e37129a55ad531439007c87c0.json b/crates/database/.sqlx/query-3d2dfd1a2638591ec261e06f26c807dbf13d2f8e37129a55ad531439007c87c0.json new file mode 100644 index 000000000..d45bdfd61 --- /dev/null +++ b/crates/database/.sqlx/query-3d2dfd1a2638591ec261e06f26c807dbf13d2f8e37129a55ad531439007c87c0.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT set_config('sourceorigin.audit_prune', 'on', true) AS \"setting!\"", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "setting!", + "type_info": "Text" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "3d2dfd1a2638591ec261e06f26c807dbf13d2f8e37129a55ad531439007c87c0" +} diff --git a/crates/database/.sqlx/query-4055d422c96ca19950221091fc9f111ec755da7c63f1af70e9f9efd6064490b4.json b/crates/database/.sqlx/query-4055d422c96ca19950221091fc9f111ec755da7c63f1af70e9f9efd6064490b4.json new file mode 100644 index 000000000..eef74f56d --- /dev/null +++ b/crates/database/.sqlx/query-4055d422c96ca19950221091fc9f111ec755da7c63f1af70e9f9efd6064490b4.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE authorization_codes SET expires_at = now() + interval '1 second' WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "4055d422c96ca19950221091fc9f111ec755da7c63f1af70e9f9efd6064490b4" +} diff --git a/crates/database/.sqlx/query-44125861f1c6f2a61f1ff32f7e959562a0023ba3be6fe90d0447fafa81e3c407.json b/crates/database/.sqlx/query-44125861f1c6f2a61f1ff32f7e959562a0023ba3be6fe90d0447fafa81e3c407.json new file mode 100644 index 000000000..501836fd8 --- /dev/null +++ b/crates/database/.sqlx/query-44125861f1c6f2a61f1ff32f7e959562a0023ba3be6fe90d0447fafa81e3c407.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT 1 AS \"one!\" FROM pg_sleep(1)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "one!", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "44125861f1c6f2a61f1ff32f7e959562a0023ba3be6fe90d0447fafa81e3c407" +} diff --git a/crates/database/.sqlx/query-567fbdd9229f018ce0171f39068442160f888156843c137dac82a5b8ac141099.json b/crates/database/.sqlx/query-567fbdd9229f018ce0171f39068442160f888156843c137dac82a5b8ac141099.json new file mode 100644 index 000000000..a709ad7f3 --- /dev/null +++ b/crates/database/.sqlx/query-567fbdd9229f018ce0171f39068442160f888156843c137dac82a5b8ac141099.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE refresh_token_families SET scopes='[1]'\n WHERE id=(SELECT family_id FROM refresh_tokens WHERE id=$1)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "567fbdd9229f018ce0171f39068442160f888156843c137dac82a5b8ac141099" +} diff --git a/crates/database/.sqlx/query-5dedc1a2182d0d61c2d02d2a8a0a805a734c9e8dbb4c6223e892b555537d2948.json b/crates/database/.sqlx/query-5dedc1a2182d0d61c2d02d2a8a0a805a734c9e8dbb4c6223e892b555537d2948.json new file mode 100644 index 000000000..cb91e2e05 --- /dev/null +++ b/crates/database/.sqlx/query-5dedc1a2182d0d61c2d02d2a8a0a805a734c9e8dbb4c6223e892b555537d2948.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE sessions SET revoked_at = now() WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "5dedc1a2182d0d61c2d02d2a8a0a805a734c9e8dbb4c6223e892b555537d2948" +} diff --git a/crates/database/.sqlx/query-5edc133349cdc977a40117f35ce123a37da056e46aaae34077f03451b8517096.json b/crates/database/.sqlx/query-5edc133349cdc977a40117f35ce123a37da056e46aaae34077f03451b8517096.json new file mode 100644 index 000000000..169028dfa --- /dev/null +++ b/crates/database/.sqlx/query-5edc133349cdc977a40117f35ce123a37da056e46aaae34077f03451b8517096.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE account_recoveries\n SET completed_at = completed_at - interval '15 days',\n settles_at = clock_timestamp()\n WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "5edc133349cdc977a40117f35ce123a37da056e46aaae34077f03451b8517096" +} diff --git a/crates/database/.sqlx/query-5f68dd1dabcd0aef032253f185fac233b60ccd3d2eb697ec2bf38873bb73b14a.json b/crates/database/.sqlx/query-5f68dd1dabcd0aef032253f185fac233b60ccd3d2eb697ec2bf38873bb73b14a.json new file mode 100644 index 000000000..37f7a91ac --- /dev/null +++ b/crates/database/.sqlx/query-5f68dd1dabcd0aef032253f185fac233b60ccd3d2eb697ec2bf38873bb73b14a.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO alerts (id, payload, version, cleared_at) VALUES ($1, $2, 1, now())", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Jsonb" + ] + }, + "nullable": [] + }, + "hash": "5f68dd1dabcd0aef032253f185fac233b60ccd3d2eb697ec2bf38873bb73b14a" +} diff --git a/crates/database/.sqlx/query-624b79eb811fdaf725956eb5ec726759b2670b734ddc919b58a2f7f6dd007761.json b/crates/database/.sqlx/query-624b79eb811fdaf725956eb5ec726759b2670b734ddc919b58a2f7f6dd007761.json new file mode 100644 index 000000000..7f6de1c2c --- /dev/null +++ b/crates/database/.sqlx/query-624b79eb811fdaf725956eb5ec726759b2670b734ddc919b58a2f7f6dd007761.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO passkey_credentials (id, credential_id, user_id, credential, friendly_name)\n SELECT uuidv7(), uuid_send(uuidv7()), $1, '{}', 'Passkey test'\n FROM generate_series(1, 100)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "624b79eb811fdaf725956eb5ec726759b2670b734ddc919b58a2f7f6dd007761" +} diff --git a/crates/database/.sqlx/query-6352457fcc167317cfa6202be195e74fdb2a95b045c4701fb6a5bcbba382e6b0.json b/crates/database/.sqlx/query-6352457fcc167317cfa6202be195e74fdb2a95b045c4701fb6a5bcbba382e6b0.json new file mode 100644 index 000000000..fb2e94772 --- /dev/null +++ b/crates/database/.sqlx/query-6352457fcc167317cfa6202be195e74fdb2a95b045c4701fb6a5bcbba382e6b0.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE passkey_credentials SET revoked_at = now() WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "6352457fcc167317cfa6202be195e74fdb2a95b045c4701fb6a5bcbba382e6b0" +} diff --git a/crates/database/.sqlx/query-7b3f682402c23d9fa1c4713a95d09c9e42640d524355bfaf2145c638654714c5.json b/crates/database/.sqlx/query-7b3f682402c23d9fa1c4713a95d09c9e42640d524355bfaf2145c638654714c5.json new file mode 100644 index 000000000..f634913e5 --- /dev/null +++ b/crates/database/.sqlx/query-7b3f682402c23d9fa1c4713a95d09c9e42640d524355bfaf2145c638654714c5.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "ROLLBACK TO duplicate_email", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "7b3f682402c23d9fa1c4713a95d09c9e42640d524355bfaf2145c638654714c5" +} diff --git a/crates/database/.sqlx/query-7cb1971da5b133923ff51d706f2f2eb4140a02c186e034eb1eddcd13953d34b6.json b/crates/database/.sqlx/query-7cb1971da5b133923ff51d706f2f2eb4140a02c186e034eb1eddcd13953d34b6.json new file mode 100644 index 000000000..978ef0bcc --- /dev/null +++ b/crates/database/.sqlx/query-7cb1971da5b133923ff51d706f2f2eb4140a02c186e034eb1eddcd13953d34b6.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO sessions(id,user_id,authentication_methods,authenticated_at,expires_at,last_seen_at)\n VALUES($1,$2,'[\"unknown\"]',now(),now()+interval '1 day',now())", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "7cb1971da5b133923ff51d706f2f2eb4140a02c186e034eb1eddcd13953d34b6" +} diff --git a/crates/database/.sqlx/query-7da42dce4238428b0ed0451398230bc7ae7ff680018c86a8b19c86601f4287f0.json b/crates/database/.sqlx/query-7da42dce4238428b0ed0451398230bc7ae7ff680018c86a8b19c86601f4287f0.json new file mode 100644 index 000000000..a2a77b2a1 --- /dev/null +++ b/crates/database/.sqlx/query-7da42dce4238428b0ed0451398230bc7ae7ff680018c86a8b19c86601f4287f0.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO request_limits (bucket, requests, expires_at)\n VALUES ($1, 1, now() - interval '1 minute')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Bytea" + ] + }, + "nullable": [] + }, + "hash": "7da42dce4238428b0ed0451398230bc7ae7ff680018c86a8b19c86601f4287f0" +} diff --git a/crates/database/.sqlx/query-7ea7b1122936117c7ea1adfa5625c1bdb970a6377d315ae460948c62bd80eae3.json b/crates/database/.sqlx/query-7ea7b1122936117c7ea1adfa5625c1bdb970a6377d315ae460948c62bd80eae3.json new file mode 100644 index 000000000..079fdadf5 --- /dev/null +++ b/crates/database/.sqlx/query-7ea7b1122936117c7ea1adfa5625c1bdb970a6377d315ae460948c62bd80eae3.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO event_personal_data (event_id, details)\n VALUES ($1, '{\"/origin\": \"https://a.example\", \"/name\": \"A\"}')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "7ea7b1122936117c7ea1adfa5625c1bdb970a6377d315ae460948c62bd80eae3" +} diff --git a/crates/database/.sqlx/query-8027870bb7abf353a8b783f60866d3c9e19b42a09c0d2e3e32fb7d62e56652c2.json b/crates/database/.sqlx/query-8027870bb7abf353a8b783f60866d3c9e19b42a09c0d2e3e32fb7d62e56652c2.json new file mode 100644 index 000000000..f05667d2a --- /dev/null +++ b/crates/database/.sqlx/query-8027870bb7abf353a8b783f60866d3c9e19b42a09c0d2e3e32fb7d62e56652c2.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE user_emails SET verified_at=NULL,is_primary=false WHERE id=$1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "8027870bb7abf353a8b783f60866d3c9e19b42a09c0d2e3e32fb7d62e56652c2" +} diff --git a/crates/database/.sqlx/query-8073bb847af49b76c2acd3fe9c21b78f99747df3e307b57f01f6344105311626.json b/crates/database/.sqlx/query-8073bb847af49b76c2acd3fe9c21b78f99747df3e307b57f01f6344105311626.json new file mode 100644 index 000000000..d7eb673bc --- /dev/null +++ b/crates/database/.sqlx/query-8073bb847af49b76c2acd3fe9c21b78f99747df3e307b57f01f6344105311626.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO domain_events (id, kind, version, payload, actor)\n VALUES (uuidv7(), 'test', 1, '{}', '{}')", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "8073bb847af49b76c2acd3fe9c21b78f99747df3e307b57f01f6344105311626" +} diff --git a/crates/database/.sqlx/query-8578e65b20c82f23a2bff6cec514af7ebff1fa55f683fee715760bf41c22babd.json b/crates/database/.sqlx/query-8578e65b20c82f23a2bff6cec514af7ebff1fa55f683fee715760bf41c22babd.json new file mode 100644 index 000000000..4e167e7e0 --- /dev/null +++ b/crates/database/.sqlx/query-8578e65b20c82f23a2bff6cec514af7ebff1fa55f683fee715760bf41c22babd.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO users(id,display_name) VALUES($1,'Decode test')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "8578e65b20c82f23a2bff6cec514af7ebff1fa55f683fee715760bf41c22babd" +} diff --git a/crates/database/.sqlx/query-93d454116adce8a7eb127e64f5f3e3553b816910e48b6b3e75da27046bf70126.json b/crates/database/.sqlx/query-93d454116adce8a7eb127e64f5f3e3553b816910e48b6b3e75da27046bf70126.json new file mode 100644 index 000000000..98a8a0e22 --- /dev/null +++ b/crates/database/.sqlx/query-93d454116adce8a7eb127e64f5f3e3553b816910e48b6b3e75da27046bf70126.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO user_emails (id, user_id, normalized_email, verified_at, is_primary)\n VALUES ($1, $2, $3, now(), true)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "93d454116adce8a7eb127e64f5f3e3553b816910e48b6b3e75da27046bf70126" +} diff --git a/crates/database/.sqlx/query-96090b62d6e14a6a0b598caaaa41a6c7f78eaa9c8b9d4537a530d8caa97a0812.json b/crates/database/.sqlx/query-96090b62d6e14a6a0b598caaaa41a6c7f78eaa9c8b9d4537a530d8caa97a0812.json new file mode 100644 index 000000000..a8f01504c --- /dev/null +++ b/crates/database/.sqlx/query-96090b62d6e14a6a0b598caaaa41a6c7f78eaa9c8b9d4537a530d8caa97a0812.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "SAVEPOINT duplicate_email", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "96090b62d6e14a6a0b598caaaa41a6c7f78eaa9c8b9d4537a530d8caa97a0812" +} diff --git a/crates/database/.sqlx/query-977e04aab4fa4e0c45f535e9818898247f82418c7cb9a8c894431a65efcc9745.json b/crates/database/.sqlx/query-977e04aab4fa4e0c45f535e9818898247f82418c7cb9a8c894431a65efcc9745.json new file mode 100644 index 000000000..f38151a64 --- /dev/null +++ b/crates/database/.sqlx/query-977e04aab4fa4e0c45f535e9818898247f82418c7cb9a8c894431a65efcc9745.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO user_emails (id, user_id, normalized_email, verified_at, is_primary)\n VALUES ($1, $2, $3, now(), true)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text" + ] + }, + "nullable": [] + }, + "hash": "977e04aab4fa4e0c45f535e9818898247f82418c7cb9a8c894431a65efcc9745" +} diff --git a/crates/database/.sqlx/query-a41f0f3c3967f203edd40c0ce4ed61329d3465c906fe89f94636e3533f8a1449.json b/crates/database/.sqlx/query-a41f0f3c3967f203edd40c0ce4ed61329d3465c906fe89f94636e3533f8a1449.json new file mode 100644 index 000000000..aea29eb04 --- /dev/null +++ b/crates/database/.sqlx/query-a41f0f3c3967f203edd40c0ce4ed61329d3465c906fe89f94636e3533f8a1449.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE deliveries SET next_attempt_at = now() WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "a41f0f3c3967f203edd40c0ce4ed61329d3465c906fe89f94636e3533f8a1449" +} diff --git a/crates/database/.sqlx/query-a59e885ca48631e8589a780ba5a049b1e7adc0f53ebcf74f643d5520d24d0ffc.json b/crates/database/.sqlx/query-a59e885ca48631e8589a780ba5a049b1e7adc0f53ebcf74f643d5520d24d0ffc.json new file mode 100644 index 000000000..d6cdaaa4d --- /dev/null +++ b/crates/database/.sqlx/query-a59e885ca48631e8589a780ba5a049b1e7adc0f53ebcf74f643d5520d24d0ffc.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE authorization_codes SET consumed_at=now() WHERE client_id=$1 AND $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Bool" + ] + }, + "nullable": [] + }, + "hash": "a59e885ca48631e8589a780ba5a049b1e7adc0f53ebcf74f643d5520d24d0ffc" +} diff --git a/crates/database/.sqlx/query-ab465e8916a95b580112655a1cbc6f028046112e25d4470b9339075e5eb5a7c1.json b/crates/database/.sqlx/query-ab465e8916a95b580112655a1cbc6f028046112e25d4470b9339075e5eb5a7c1.json new file mode 100644 index 000000000..09acd06d2 --- /dev/null +++ b/crates/database/.sqlx/query-ab465e8916a95b580112655a1cbc6f028046112e25d4470b9339075e5eb5a7c1.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT 1 AS \"one!\" FROM sessions WHERE id = $1 FOR UPDATE NOWAIT", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "one!", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "ab465e8916a95b580112655a1cbc6f028046112e25d4470b9339075e5eb5a7c1" +} diff --git a/crates/database/.sqlx/query-ad347b7d4332cc0f5a7f5fad99278a147cbcaa845370fc34c9ad81099c34867f.json b/crates/database/.sqlx/query-ad347b7d4332cc0f5a7f5fad99278a147cbcaa845370fc34c9ad81099c34867f.json new file mode 100644 index 000000000..4038c62e7 --- /dev/null +++ b/crates/database/.sqlx/query-ad347b7d4332cc0f5a7f5fad99278a147cbcaa845370fc34c9ad81099c34867f.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE passkey_credentials SET revoked_at = now()\n WHERE id = (SELECT id FROM passkey_credentials WHERE user_id = $1 LIMIT 1)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "ad347b7d4332cc0f5a7f5fad99278a147cbcaa845370fc34c9ad81099c34867f" +} diff --git a/crates/database/.sqlx/query-ade235724b233bf497229734c76399c92c6c87acc84b5858df4de8a6140cfde9.json b/crates/database/.sqlx/query-ade235724b233bf497229734c76399c92c6c87acc84b5858df4de8a6140cfde9.json new file mode 100644 index 000000000..321d5be86 --- /dev/null +++ b/crates/database/.sqlx/query-ade235724b233bf497229734c76399c92c6c87acc84b5858df4de8a6140cfde9.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT 1 AS \"one!\" FROM users WHERE id = $1 FOR NO KEY UPDATE NOWAIT", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "one!", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "ade235724b233bf497229734c76399c92c6c87acc84b5858df4de8a6140cfde9" +} diff --git a/crates/database/.sqlx/query-adf06711fd97cdca457765f091a2b3c1741b37c42484b0f3d691113330babd51.json b/crates/database/.sqlx/query-adf06711fd97cdca457765f091a2b3c1741b37c42484b0f3d691113330babd51.json new file mode 100644 index 000000000..d50518c67 --- /dev/null +++ b/crates/database/.sqlx/query-adf06711fd97cdca457765f091a2b3c1741b37c42484b0f3d691113330babd51.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE sessions SET last_seen_at = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "adf06711fd97cdca457765f091a2b3c1741b37c42484b0f3d691113330babd51" +} diff --git a/crates/database/.sqlx/query-b81ac5aea158f98eb10c23d67060325528e27d8359b3cf9e610f7ec08e8eb749.json b/crates/database/.sqlx/query-b81ac5aea158f98eb10c23d67060325528e27d8359b3cf9e610f7ec08e8eb749.json new file mode 100644 index 000000000..2478af0c9 --- /dev/null +++ b/crates/database/.sqlx/query-b81ac5aea158f98eb10c23d67060325528e27d8359b3cf9e610f7ec08e8eb749.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE handles SET released_at = now() - interval '366 days' WHERE handle = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "b81ac5aea158f98eb10c23d67060325528e27d8359b3cf9e610f7ec08e8eb749" +} diff --git a/crates/database/.sqlx/query-b847bb9d51b0ddb07e7e8046e35a420cd8b1038b2ce882eb75ce7da9b5713b87.json b/crates/database/.sqlx/query-b847bb9d51b0ddb07e7e8046e35a420cd8b1038b2ce882eb75ce7da9b5713b87.json new file mode 100644 index 000000000..9d3820667 --- /dev/null +++ b/crates/database/.sqlx/query-b847bb9d51b0ddb07e7e8046e35a420cd8b1038b2ce882eb75ce7da9b5713b87.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT 1 AS \"one!\" FROM request_limits WHERE bucket=$1 FOR UPDATE", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "one!", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Bytea" + ] + }, + "nullable": [ + null + ] + }, + "hash": "b847bb9d51b0ddb07e7e8046e35a420cd8b1038b2ce882eb75ce7da9b5713b87" +} diff --git a/crates/database/.sqlx/query-bbeedb3178664eae0a48505e300d6377d76d7b8278ba6aeb89b08cd21a7c65fe.json b/crates/database/.sqlx/query-bbeedb3178664eae0a48505e300d6377d76d7b8278ba6aeb89b08cd21a7c65fe.json new file mode 100644 index 000000000..521cc0db4 --- /dev/null +++ b/crates/database/.sqlx/query-bbeedb3178664eae0a48505e300d6377d76d7b8278ba6aeb89b08cd21a7c65fe.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM oidc_redirect_uris WHERE client_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "bbeedb3178664eae0a48505e300d6377d76d7b8278ba6aeb89b08cd21a7c65fe" +} diff --git a/crates/database/.sqlx/query-bfed2a9291db69c73d31e142c108bfe92e53aacb020f3e7e4dadb60ab6889ccc.json b/crates/database/.sqlx/query-bfed2a9291db69c73d31e142c108bfe92e53aacb020f3e7e4dadb60ab6889ccc.json new file mode 100644 index 000000000..3962b46f5 --- /dev/null +++ b/crates/database/.sqlx/query-bfed2a9291db69c73d31e142c108bfe92e53aacb020f3e7e4dadb60ab6889ccc.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT 1 AS \"one!\" FROM pg_advisory_xact_lock($1)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "one!", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + null + ] + }, + "hash": "bfed2a9291db69c73d31e142c108bfe92e53aacb020f3e7e4dadb60ab6889ccc" +} diff --git a/crates/database/.sqlx/query-c6ced81f2982ede3f48f62da010220dcb1a7e4ff72217815a68246e65c0475d3.json b/crates/database/.sqlx/query-c6ced81f2982ede3f48f62da010220dcb1a7e4ff72217815a68246e65c0475d3.json new file mode 100644 index 000000000..c613e0b12 --- /dev/null +++ b/crates/database/.sqlx/query-c6ced81f2982ede3f48f62da010220dcb1a7e4ff72217815a68246e65c0475d3.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE domain_events\n SET chain_position = chain_position, chain_hash = chain_hash, chain_format = chain_format\n WHERE false", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "c6ced81f2982ede3f48f62da010220dcb1a7e4ff72217815a68246e65c0475d3" +} diff --git a/crates/database/.sqlx/query-c745cbdcd90e49903c172adba06dcf7db7a225b68bd448dc5fa9a1323bdf29a6.json b/crates/database/.sqlx/query-c745cbdcd90e49903c172adba06dcf7db7a225b68bd448dc5fa9a1323bdf29a6.json new file mode 100644 index 000000000..f262256cc --- /dev/null +++ b/crates/database/.sqlx/query-c745cbdcd90e49903c172adba06dcf7db7a225b68bd448dc5fa9a1323bdf29a6.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO oidc_redirect_uris (client_id, uri, kind, origin)\n VALUES ($1, $2, 'authorization', 'https://client.example')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "c745cbdcd90e49903c172adba06dcf7db7a225b68bd448dc5fa9a1323bdf29a6" +} diff --git a/crates/database/.sqlx/query-cc49b8883302209859b67ac5eb6b8a3a1821dc3928d2ccba8f9829410a478f2e.json b/crates/database/.sqlx/query-cc49b8883302209859b67ac5eb6b8a3a1821dc3928d2ccba8f9829410a478f2e.json new file mode 100644 index 000000000..6d15fa652 --- /dev/null +++ b/crates/database/.sqlx/query-cc49b8883302209859b67ac5eb6b8a3a1821dc3928d2ccba8f9829410a478f2e.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO passkey_credentials (id, credential_id, user_id, credential, friendly_name)\n VALUES ($1, uuid_send($1), $2, '{}', 'Restore test')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "cc49b8883302209859b67ac5eb6b8a3a1821dc3928d2ccba8f9829410a478f2e" +} diff --git a/crates/database/.sqlx/query-d056d984a7c40db9ce0dfd4871248c64ed3fccf337b5caf4f065fcb71c264d33.json b/crates/database/.sqlx/query-d056d984a7c40db9ce0dfd4871248c64ed3fccf337b5caf4f065fcb71c264d33.json new file mode 100644 index 000000000..61c5ef55c --- /dev/null +++ b/crates/database/.sqlx/query-d056d984a7c40db9ce0dfd4871248c64ed3fccf337b5caf4f065fcb71c264d33.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO notifications (id, user_id, payload)\n VALUES ($1, $2, '{\"kind\": \"from_a_newer_release\"}')", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "d056d984a7c40db9ce0dfd4871248c64ed3fccf337b5caf4f065fcb71c264d33" +} diff --git a/crates/database/.sqlx/query-d8f9f3eb84e854af9dd9eec77a5fffa9fa5671de10cdd35b6351d0a3e75521af.json b/crates/database/.sqlx/query-d8f9f3eb84e854af9dd9eec77a5fffa9fa5671de10cdd35b6351d0a3e75521af.json new file mode 100644 index 000000000..b95639721 --- /dev/null +++ b/crates/database/.sqlx/query-d8f9f3eb84e854af9dd9eec77a5fffa9fa5671de10cdd35b6351d0a3e75521af.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO oidc_clients (\n id, display_name, allowed_scopes, allowed_audiences, allow_refresh\n ) VALUES ($1, 'Lock test', '[\"openid\"]', '[\"test\"]', true)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "d8f9f3eb84e854af9dd9eec77a5fffa9fa5671de10cdd35b6351d0a3e75521af" +} diff --git a/crates/database/.sqlx/query-d93bd9fe95575e093efded932dd8057053ddf49bb914daf5777e7f745302af4c.json b/crates/database/.sqlx/query-d93bd9fe95575e093efded932dd8057053ddf49bb914daf5777e7f745302af4c.json new file mode 100644 index 000000000..140b9948c --- /dev/null +++ b/crates/database/.sqlx/query-d93bd9fe95575e093efded932dd8057053ddf49bb914daf5777e7f745302af4c.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM event_personal_data WHERE event_id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "d93bd9fe95575e093efded932dd8057053ddf49bb914daf5777e7f745302af4c" +} diff --git a/crates/database/.sqlx/query-dd295fef074da7b9434073cc99c857c8e2fc4154114b3b552553c5aacfa5f8f3.json b/crates/database/.sqlx/query-dd295fef074da7b9434073cc99c857c8e2fc4154114b3b552553c5aacfa5f8f3.json new file mode 100644 index 000000000..80e573441 --- /dev/null +++ b/crates/database/.sqlx/query-dd295fef074da7b9434073cc99c857c8e2fc4154114b3b552553c5aacfa5f8f3.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT 1 AS \"one!\" FROM refresh_token_families WHERE id = $1 FOR UPDATE NOWAIT", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "one!", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + null + ] + }, + "hash": "dd295fef074da7b9434073cc99c857c8e2fc4154114b3b552553c5aacfa5f8f3" +} diff --git a/crates/database/.sqlx/query-e1ec0385b79cfbf13cbe28a38dbd77b81a282fb41b17bc4808e0d4a6c6968efa.json b/crates/database/.sqlx/query-e1ec0385b79cfbf13cbe28a38dbd77b81a282fb41b17bc4808e0d4a6c6968efa.json new file mode 100644 index 000000000..a3c612b10 --- /dev/null +++ b/crates/database/.sqlx/query-e1ec0385b79cfbf13cbe28a38dbd77b81a282fb41b17bc4808e0d4a6c6968efa.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE user_emails SET normalized_email=normalized_email||'.new',user_id=$2 WHERE id=$1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "e1ec0385b79cfbf13cbe28a38dbd77b81a282fb41b17bc4808e0d4a6c6968efa" +} diff --git a/crates/database/.sqlx/query-e94b1b808da6f52aee96bdc6a6a1b87ef466bb8a8602f054021cf2eec47534dd.json b/crates/database/.sqlx/query-e94b1b808da6f52aee96bdc6a6a1b87ef466bb8a8602f054021cf2eec47534dd.json new file mode 100644 index 000000000..0e6ed24b0 --- /dev/null +++ b/crates/database/.sqlx/query-e94b1b808da6f52aee96bdc6a6a1b87ef466bb8a8602f054021cf2eec47534dd.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH client AS (\n INSERT INTO oidc_clients(id,display_name,allowed_scopes,allowed_audiences,backchannel_logout_uri)\n VALUES($1,'Logout test','[]','[]',$2) RETURNING id\n )\n INSERT INTO authorization_codes(id,secret_digest,client_id,user_id,session_id,\n redirect_uri,pkce_challenge,scopes,audience,expires_at,authentication,digest_key)\n SELECT gen_random_uuid(),uuid_send(gen_random_uuid()),id,$3,$4,\n 'https://app.example/callback','challenge','[]',id,now()+interval '1 minute','{}',\n 'test'\n FROM client", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text", + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "e94b1b808da6f52aee96bdc6a6a1b87ef466bb8a8602f054021cf2eec47534dd" +} diff --git a/crates/database/.sqlx/query-fa03fd006aa3c90fa3dd844eb68d678791981a6a9a4f7516f877c60172285bda.json b/crates/database/.sqlx/query-fa03fd006aa3c90fa3dd844eb68d678791981a6a9a4f7516f877c60172285bda.json new file mode 100644 index 000000000..16158ff03 --- /dev/null +++ b/crates/database/.sqlx/query-fa03fd006aa3c90fa3dd844eb68d678791981a6a9a4f7516f877c60172285bda.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM deliveries WHERE channel = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "fa03fd006aa3c90fa3dd844eb68d678791981a6a9a4f7516f877c60172285bda" +} diff --git a/crates/database/src/connection/tests.rs b/crates/database/src/connection/tests.rs index 4a6ef9c00..dad736200 100644 --- a/crates/database/src/connection/tests.rs +++ b/crates/database/src/connection/tests.rs @@ -131,20 +131,22 @@ async fn cleanup_skips_rows_locked_by_requests() { // Concurrent tests purge too and can delete the expired row before it is // locked, so insert it again until the request holds it. let request = loop { - sqlx::query( + sqlx::query!( "INSERT INTO request_limits (bucket, requests, expires_at) VALUES ($1, 1, now() - interval '1 minute')", + &bucket ) - .bind(&bucket) .execute(&pool) .await .expect("expired limit"); let mut request = pool.begin().await.expect("request transaction"); - let locked = sqlx::query("SELECT 1 FROM request_limits WHERE bucket=$1 FOR UPDATE") - .bind(&bucket) - .fetch_optional(&mut *request) - .await - .expect("lock"); + let locked = sqlx::query!( + r#"SELECT 1 AS "one!" FROM request_limits WHERE bucket=$1 FOR UPDATE"#, + &bucket + ) + .fetch_optional(&mut *request) + .await + .expect("lock"); if locked.is_some() { break request; } @@ -176,8 +178,7 @@ async fn cleanup_keeps_redeemed_codes_while_their_session_is_live() { let [user, session, code, family] = [(); 4].map(|()| uuid::Uuid::now_v7()); let client = format!("purge_{user}"); // One statement keeps the fixture short; foreign keys are checked at its end. - sqlx::query( - "WITH account AS ( + sqlx::query!("WITH account AS ( INSERT INTO users (id, display_name) VALUES ($1, 'Purge') ), browser AS ( INSERT INTO sessions ( @@ -191,20 +192,14 @@ async fn cleanup_keeps_redeemed_codes_while_their_session_is_live() { id, secret_digest, client_id, user_id, session_id, redirect_uri, pkce_challenge, scopes, audience, expires_at, consumed_at, authentication, digest_key - ) VALUES ($3, convert_to($3::text, 'UTF8'), $5, $1, $2, 'https://client.example', + ) VALUES ($3, convert_to($3::uuid::text, 'UTF8'), $5, $1, $2, 'https://client.example', 'challenge', '[]', 'test', now() - interval '2 days', now() - interval '2 days', '{}', 'test') ) INSERT INTO refresh_token_families ( id, user_id, client_id, session_id, authorization_code_id, audience, scopes, authentication - ) VALUES ($4, $1, $5, $2, $3, 'test', '[]', '{}')", - ) - .bind(user) - .bind(session) - .bind(code) - .bind(family) - .bind(&client) + ) VALUES ($4, $1, $5, $2, $3, 'test', '[]', '{}')", user, session, code, family, &client) .execute(&pool) .await .expect("redeemed grant"); @@ -223,11 +218,13 @@ async fn cleanup_keeps_redeemed_codes_while_their_session_is_live() { .await .expect("purge"); assert_eq!(link().await, Some(code), "a live grant keeps its code"); - sqlx::query("UPDATE sessions SET revoked_at = now() WHERE id = $1") - .bind(session) - .execute(&pool) - .await - .expect("end session"); + sqlx::query!( + "UPDATE sessions SET revoked_at = now() WHERE id = $1", + session + ) + .execute(&pool) + .await + .expect("end session"); database .maintenance() .purge_expired_auth_state(1000) @@ -283,6 +280,10 @@ fn runtime_roles_need_plain_names() { /// service's cleanup still works with it, and overlapping provisioning runs are safe. #[tokio::test] #[ignore = "requires a disposable TEST_DATABASE_URL"] +#[expect( + clippy::disallowed_methods, + reason = "Each listed statement, DDL and `COPY` included, runs as the runtime role to see it refused" +)] async fn runtime_role_has_only_row_privileges() { let owner = Database::test().await; let name = format!("sourceorigin_auth_{}", uuid::Uuid::now_v7().simple()); @@ -299,9 +300,9 @@ async fn runtime_role_has_only_row_privileges() { // Rolled back, since other tests consume every event. let mut append = runtime.pool.begin().await.expect("begin"); - sqlx::query( + sqlx::query!( "INSERT INTO domain_events (id, kind, version, payload, actor) - VALUES (uuidv7(), 'test', 1, '{}', '{}')", + VALUES (uuidv7(), 'test', 1, '{}', '{}')" ) .execute(&mut *append) .await @@ -322,10 +323,10 @@ async fn runtime_role_has_only_row_privileges() { .await .expect("lock unsealed events"); seal.rollback().await.expect("rollback"); - sqlx::query( + sqlx::query!( "UPDATE domain_events SET chain_position = chain_position, chain_hash = chain_hash, chain_format = chain_format - WHERE false", + WHERE false" ) .execute(&runtime.pool) .await @@ -555,8 +556,8 @@ async fn statements_and_lock_waits_past_their_limits_fail() { .fetch_one(&mut *slow.inner) .await .expect("statement limit"); - let cancelled = sqlx::query("SELECT pg_sleep(1)") - .execute(&mut *slow.inner) + let cancelled = sqlx::query!(r#"SELECT 1 AS "one!" FROM pg_sleep(1)"#) + .fetch_all(&mut *slow.inner) .await .map_err(DatabaseError::from); assert!( @@ -568,9 +569,8 @@ async fn statements_and_lock_waits_past_their_limits_fail() { // A key no other test takes. let key = i64::from_be_bytes(*b"timeout!"); let mut holder = database.begin().await.expect("transaction"); - sqlx::query("SELECT pg_advisory_xact_lock($1)") - .bind(key) - .execute(&mut *holder.inner) + sqlx::query!(r#"SELECT 1 AS "one!" FROM pg_advisory_xact_lock($1)"#, key) + .fetch_all(&mut *holder.inner) .await .expect("lock"); let mut waiter = database.begin().await.expect("transaction"); @@ -580,9 +580,8 @@ async fn statements_and_lock_waits_past_their_limits_fail() { .fetch_one(&mut *waiter.inner) .await .expect("lock limit"); - let unavailable = sqlx::query("SELECT pg_advisory_xact_lock($1)") - .bind(key) - .execute(&mut *waiter.inner) + let unavailable = sqlx::query!(r#"SELECT 1 AS "one!" FROM pg_advisory_xact_lock($1)"#, key) + .fetch_all(&mut *waiter.inner) .await .map_err(DatabaseError::from); assert!( @@ -616,6 +615,10 @@ async fn insert_event(connection: &mut PgConnection) -> Uuid { /// Erasing a purged owner's origins removes values from `details` as `runtime`; /// no update may add or change one. +#[expect( + clippy::disallowed_methods, + reason = "Each listed `UPDATE` runs as the runtime role to see it allowed or refused" +)] async fn assert_personal_data_only_erases(runtime: &Database) { for (statement, allowed) in [ ( @@ -629,11 +632,11 @@ async fn assert_personal_data_only_erases(runtime: &Database) { ] { let mut probe = runtime.pool.begin().await.expect("begin"); let event = insert_event(&mut probe).await; - sqlx::query( + sqlx::query!( "INSERT INTO event_personal_data (event_id, details) VALUES ($1, '{\"/origin\": \"https://a.example\", \"/name\": \"A\"}')", + event ) - .bind(event) .execute(&mut *probe) .await .expect("personal data"); @@ -656,6 +659,10 @@ async fn assert_personal_data_only_erases(runtime: &Database) { /// inserts must be JSON auth can read back, or sealing would fail on it. /// `personal_data_is_recorded_only_with_its_event` covers attaching personal data /// to an older event, which needs a committed event, so a schema of its own. +#[expect( + clippy::disallowed_methods, + reason = "`refusal` takes a statement to run as the runtime role, and a payload is bound as text, which `query!` cannot check against `jsonb`" +)] async fn assert_history_is_never_forged(runtime: &Database) { for payload in [ r#"{"n": 1e400}"#.to_owned(), diff --git a/crates/database/src/repositories/audit/mod.rs b/crates/database/src/repositories/audit/mod.rs index d1898b734..939bbde10 100644 --- a/crates/database/src/repositories/audit/mod.rs +++ b/crates/database/src/repositories/audit/mod.rs @@ -653,6 +653,10 @@ impl AuditRepository<'_> { /// Enables or disables the guard triggers of every audit table, for /// [`Self::tamper`]. + #[expect( + clippy::disallowed_methods, + reason = "DDL takes no bind parameters, so the statement is formatted from literals" + )] async fn guards(&mut self, enabled: bool) -> Result<(), DatabaseError> { let toggle = if enabled { "ENABLE" } else { "DISABLE" }; for table in ["domain_events", "audit_checkpoints", "audit_anchor"] { diff --git a/crates/database/src/repositories/audit/tests.rs b/crates/database/src/repositories/audit/tests.rs index 2cc775724..c8abcaab9 100644 --- a/crates/database/src/repositories/audit/tests.rs +++ b/crates/database/src/repositories/audit/tests.rs @@ -6,6 +6,10 @@ use uuid::Uuid; /// Runs `sql`, bound to `id`, in a savepoint, so a refusal leaves the surrounding /// transaction usable. Returns the error code of a refusal. +#[expect( + clippy::disallowed_methods, + reason = "Callers pass each guarded statement, to see it refused" +)] async fn attempt(connection: &mut PgConnection, sql: &str, id: Uuid) -> Result<(), String> { let mut savepoint = connection.begin().await.expect("savepoint"); let result = sqlx::query(sql).bind(id).execute(&mut *savepoint).await; @@ -118,8 +122,8 @@ async fn sealed_history_is_guarded() { refused, "only pruning anchors" ); - sqlx::query("SELECT set_config('sourceorigin.audit_prune', 'on', true)") - .execute(&mut *tx) + sqlx::query!(r#"SELECT set_config('sourceorigin.audit_prune', 'on', true) AS "setting!""#) + .fetch_one(&mut *tx) .await .expect("prune setting"); assert_eq!( diff --git a/crates/database/src/repositories/deletions/tests.rs b/crates/database/src/repositories/deletions/tests.rs index f1e310923..879b28f22 100644 --- a/crates/database/src/repositories/deletions/tests.rs +++ b/crates/database/src/repositories/deletions/tests.rs @@ -36,12 +36,12 @@ async fn restore_tokens_expire_and_end_with_the_deletion() { let (old, new, expired) = ([1; 32], [2; 32], [3; 32]); let passkey = PasskeyId::new(); - sqlx::query( + sqlx::query!( "INSERT INTO passkey_credentials (id, credential_id, user_id, credential, friendly_name) VALUES ($1, uuid_send($1), $2, '{}', 'Restore test')", + passkey.as_uuid(), + user.as_uuid() ) - .bind(passkey.as_uuid()) - .bind(user.as_uuid()) .execute(&pool) .await .expect("passkey"); @@ -64,11 +64,13 @@ async fn restore_tokens_expire_and_end_with_the_deletion() { passkey_id: passkey }) ); - sqlx::query("UPDATE passkey_credentials SET revoked_at = now() WHERE id = $1") - .bind(passkey.as_uuid()) - .execute(&pool) - .await - .expect("revoke"); + sqlx::query!( + "UPDATE passkey_credentials SET revoked_at = now() WHERE id = $1", + passkey.as_uuid() + ) + .execute(&pool) + .await + .expect("revoke"); assert_eq!( deletions .find_by_restore_token(&new) diff --git a/crates/database/src/repositories/deliveries/tests.rs b/crates/database/src/repositories/deliveries/tests.rs index b12fcfb93..e2e5e4c1d 100644 --- a/crates/database/src/repositories/deliveries/tests.rs +++ b/crates/database/src/repositories/deliveries/tests.rs @@ -85,8 +85,7 @@ impl Channel for Recorder { /// Deletes the deliveries a previous run left on `C`. async fn clear(pool: &PgPool) { - sqlx::query("DELETE FROM deliveries WHERE channel = $1") - .bind(C::NAME) + sqlx::query!("DELETE FROM deliveries WHERE channel = $1", C::NAME) .execute(pool) .await .expect("clear channel"); @@ -418,11 +417,13 @@ async fn an_older_release_leaves_a_delivery_it_cannot_decode_to_a_newer_one() { // The new release claims it once it is due again. assert!(claim::(&pool, LEASE).await.is_none()); - sqlx::query("UPDATE deliveries SET next_attempt_at = now() WHERE id = $1") - .bind(added.as_uuid()) - .execute(&pool) - .await - .expect("due"); + sqlx::query!( + "UPDATE deliveries SET next_attempt_at = now() WHERE id = $1", + added.as_uuid() + ) + .execute(&pool) + .await + .expect("due"); let new = claim::(&pool, LEASE) .await .expect("the new release sends it"); @@ -481,8 +482,7 @@ async fn revoking_a_session_queues_a_logout_token_for_each_client_to_tell() { ] { // Each client gets a code from the session, which it redeems as every // release does, the previous one included. - sqlx::query( - "WITH client AS ( + sqlx::query!("WITH client AS ( INSERT INTO oidc_clients(id,display_name,allowed_scopes,allowed_audiences,backchannel_logout_uri) VALUES($1,'Logout test','[]','[]',$2) RETURNING id ) @@ -491,21 +491,18 @@ async fn revoking_a_session_queues_a_logout_token_for_each_client_to_tell() { SELECT gen_random_uuid(),uuid_send(gen_random_uuid()),id,$3,$4, 'https://app.example/callback','challenge','[]',id,now()+interval '1 minute','{}', 'test' - FROM client", - ) - .bind(&client) - .bind(uri) - .bind(user.as_uuid()) - .bind(session.as_uuid()) + FROM client", &client, uri, user.as_uuid(), session.as_uuid()) .execute(&pool) .await .expect("client and code"); - sqlx::query("UPDATE authorization_codes SET consumed_at=now() WHERE client_id=$1 AND $2") - .bind(&client) - .bind(redeemed) - .execute(&pool) - .await - .expect("redeem"); + sqlx::query!( + "UPDATE authorization_codes SET consumed_at=now() WHERE client_id=$1 AND $2", + &client, + redeemed + ) + .execute(&pool) + .await + .expect("redeem"); } let revoke = async |commit: bool| { let mut tx = DatabaseTransaction::new(pool.begin().await.expect("transaction")); diff --git a/crates/database/src/repositories/emails/tests.rs b/crates/database/src/repositories/emails/tests.rs index abba66de3..8873dbf7c 100644 --- a/crates/database/src/repositories/emails/tests.rs +++ b/crates/database/src/repositories/emails/tests.rs @@ -20,16 +20,20 @@ async fn verified_email_updates_preserve_and_release_ownership() { ]; let email = uuid::Uuid::now_v7(); let address = format!("{email}@example.test"); - sqlx::query( + sqlx::query!( "INSERT INTO user_emails (id, user_id, normalized_email, verified_at, is_primary) VALUES ($1, $2, $3, now(), true)", + email, + users[0].as_uuid(), + &address ) - .bind(email) - .bind(users[0].as_uuid()) - .bind(&address) .execute(&mut *tx) .await .expect("email"); + #[expect( + clippy::disallowed_methods, + reason = "The `SET` clause is the loop's variable" + )] for update in [ "verified_at=verified_at", "verified_at=now()+interval '1 second'", @@ -48,31 +52,31 @@ async fn verified_email_updates_preserve_and_release_ownership() { .expect("ownership retained"); assert_eq!(owner, users[0].as_uuid()); } - sqlx::query("SAVEPOINT duplicate_email") + sqlx::query!("SAVEPOINT duplicate_email") .execute(&mut *tx) .await .expect("savepoint"); assert!( - sqlx::query( + sqlx::query!( "INSERT INTO user_emails (id, user_id, normalized_email, verified_at, is_primary) - VALUES ($1, $2, $3, now(), true)" + VALUES ($1, $2, $3, now(), true)", + uuid::Uuid::now_v7(), + users[1].as_uuid(), + &address ) - .bind(uuid::Uuid::now_v7()) - .bind(users[1].as_uuid()) - .bind(&address) .execute(&mut *tx) .await .is_err() ); - sqlx::query("ROLLBACK TO duplicate_email") + sqlx::query!("ROLLBACK TO duplicate_email") .execute(&mut *tx) .await .expect("rollback duplicate"); - sqlx::query( + sqlx::query!( "UPDATE user_emails SET normalized_email=normalized_email||'.new',user_id=$2 WHERE id=$1", + email, + users[1].as_uuid() ) - .bind(email) - .bind(users[1].as_uuid()) .execute(&mut *tx) .await .expect("move address and owner"); @@ -84,11 +88,13 @@ async fn verified_email_updates_preserve_and_release_ownership() { .await .expect("old ownership"); assert!(!old_exists); - sqlx::query("UPDATE user_emails SET verified_at=NULL,is_primary=false WHERE id=$1") - .bind(email) - .execute(&mut *tx) - .await - .expect("unverify"); + sqlx::query!( + "UPDATE user_emails SET verified_at=NULL,is_primary=false WHERE id=$1", + email + ) + .execute(&mut *tx) + .await + .expect("unverify"); let count: i64 = sqlx::query_scalar("SELECT count(*) FROM verified_email_ownership WHERE user_id=ANY($1)") .bind(users.map(UserId::as_uuid).as_slice()) @@ -96,13 +102,14 @@ async fn verified_email_updates_preserve_and_release_ownership() { .await .expect("ownership count"); assert_eq!(count, 0); - sqlx::query("UPDATE user_emails SET verified_at=now(),is_primary=true WHERE id=$1") - .bind(email) - .execute(&mut *tx) - .await - .expect("reverify"); - sqlx::query("DELETE FROM user_emails WHERE id=$1") - .bind(email) + sqlx::query!( + "UPDATE user_emails SET verified_at=now(),is_primary=true WHERE id=$1", + email + ) + .execute(&mut *tx) + .await + .expect("reverify"); + sqlx::query!("DELETE FROM user_emails WHERE id=$1", email) .execute(&mut *tx) .await .expect("delete"); @@ -113,7 +120,7 @@ async fn verified_email_updates_preserve_and_release_ownership() { .await .expect("ownership count"); assert_eq!(count, 0); - sqlx::query("SET CONSTRAINTS ALL IMMEDIATE") + sqlx::query!("SET CONSTRAINTS ALL IMMEDIATE") .execute(&mut *tx) .await .expect("primary invariants"); diff --git a/crates/database/src/repositories/events/tests.rs b/crates/database/src/repositories/events/tests.rs index 8ee495e9b..46b8d7291 100644 --- a/crates/database/src/repositories/events/tests.rs +++ b/crates/database/src/repositories/events/tests.rs @@ -108,11 +108,13 @@ async fn personal_data_is_stored_apart_and_erases() { ); } - sqlx::query("DELETE FROM event_personal_data WHERE event_id = $1") - .bind(stored.id.as_uuid()) - .execute(&pool) - .await - .expect("erase"); + sqlx::query!( + "DELETE FROM event_personal_data WHERE event_id = $1", + stored.id.as_uuid() + ) + .execute(&pool) + .await + .expect("erase"); let [erased] = <[StoredEvent; 1]>::try_from(history().await).expect("one event"); assert_eq!( erased.event, @@ -226,11 +228,11 @@ async fn related_origins_are_personal_but_older_events_still_read() { assert_eq!(payloads[1].0, 2); assert_eq!(payloads[1].1["origin"], ERASED); - sqlx::query( + sqlx::query!( "DELETE FROM event_personal_data p USING domain_events e WHERE p.event_id = e.id AND e.subject_user_id = $1", + user.as_uuid() ) - .bind(user.as_uuid()) .execute(&pool) .await .expect("erase"); @@ -309,12 +311,14 @@ async fn an_alert_updates_note_erases_with_its_event() { }); let alert_id = AlertId::new(); // Cleared, so it is not the current alert other tests raise. - sqlx::query("INSERT INTO alerts (id, payload, version, cleared_at) VALUES ($1, $2, 1, now())") - .bind(alert_id.as_uuid()) - .bind(serde_json::to_value(&alert).expect("payload")) - .execute(&pool) - .await - .expect("alert"); + sqlx::query!( + "INSERT INTO alerts (id, payload, version, cleared_at) VALUES ($1, $2, 1, now())", + alert_id.as_uuid(), + serde_json::to_value(&alert).expect("payload") + ) + .execute(&pool) + .await + .expect("alert"); let context = EventContext { actor: Actor::Cli { os_user: "ops".into(), @@ -345,10 +349,12 @@ async fn an_alert_updates_note_erases_with_its_event() { }; assert_eq!(note().await.as_deref(), Some("Restoring from backup")); - sqlx::query("DELETE FROM event_personal_data WHERE event_id = $1") - .bind(event.as_uuid()) - .execute(&pool) - .await - .expect("erase"); + sqlx::query!( + "DELETE FROM event_personal_data WHERE event_id = $1", + event.as_uuid() + ) + .execute(&pool) + .await + .expect("erase"); assert_eq!(note().await, None); } diff --git a/crates/database/src/repositories/maintenance/tests.rs b/crates/database/src/repositories/maintenance/tests.rs index 7ea7833b4..903305382 100644 --- a/crates/database/src/repositories/maintenance/tests.rs +++ b/crates/database/src/repositories/maintenance/tests.rs @@ -126,11 +126,13 @@ async fn ended_records_go_after_their_retention() { "recovery new" ] ); - sqlx::query("UPDATE handles SET released_at = now() - interval '366 days' WHERE handle = $1") - .bind(&handle.0) - .execute(&pool) - .await - .expect("a year on"); + sqlx::query!( + "UPDATE handles SET released_at = now() - interval '366 days' WHERE handle = $1", + &handle.0 + ) + .execute(&pool) + .await + .expect("a year on"); maintenance().await; assert_eq!( remaining().await, diff --git a/crates/database/src/repositories/notifications/tests.rs b/crates/database/src/repositories/notifications/tests.rs index e999f8624..79c003d3c 100644 --- a/crates/database/src/repositories/notifications/tests.rs +++ b/crates/database/src/repositories/notifications/tests.rs @@ -128,12 +128,12 @@ async fn pages_continue_across_equal_times() { #[ignore = "requires a disposable TEST_DATABASE_URL"] async fn newer_kinds_read_as_unknown() { let (database, user) = account("future").await; - sqlx::query( + sqlx::query!( r#"INSERT INTO notifications (id, user_id, payload) VALUES ($1, $2, '{"kind": "from_a_newer_release"}')"#, + NotificationId::new().as_uuid(), + user.as_uuid() ) - .bind(NotificationId::new().as_uuid()) - .bind(user.as_uuid()) .execute(&database.pool) .await .expect("insert"); diff --git a/crates/database/src/repositories/oidc/tests.rs b/crates/database/src/repositories/oidc/tests.rs index 560a4c78f..9f1c51f6e 100644 --- a/crates/database/src/repositories/oidc/tests.rs +++ b/crates/database/src/repositories/oidc/tests.rs @@ -239,8 +239,7 @@ async fn purging_an_owner_needs_its_live_clients_deleted() { .await .expect("create"); let purge = async || { - sqlx::query("DELETE FROM users WHERE id = $1") - .bind(owner.as_uuid()) + sqlx::query!("DELETE FROM users WHERE id = $1", owner.as_uuid()) .execute(&pool) .await }; diff --git a/crates/database/src/repositories/passkeys/tests.rs b/crates/database/src/repositories/passkeys/tests.rs index a7eb6bf30..128928125 100644 --- a/crates/database/src/repositories/passkeys/tests.rs +++ b/crates/database/src/repositories/passkeys/tests.rs @@ -35,11 +35,13 @@ async fn handle_lookup_hides_disabled_accounts_and_revoked_passkeys() { }; assert_eq!(listed().await, 1); if disable { - sqlx::query("UPDATE users SET status = 'disabled' WHERE id = $1") - .bind(user.as_uuid()) - .execute(&pool) - .await - .expect("disable"); + sqlx::query!( + "UPDATE users SET status = 'disabled' WHERE id = $1", + user.as_uuid() + ) + .execute(&pool) + .await + .expect("disable"); } else { assert!(passkeys.revoke(key.id, user).await.expect("revoke")); } @@ -56,12 +58,12 @@ async fn accounts_keep_at_most_100_passkeys() { let user = UserRepository::from_pool(&pool) .insert_named("passkeys") .await; - sqlx::query( + sqlx::query!( "INSERT INTO passkey_credentials (id, credential_id, user_id, credential, friendly_name) SELECT uuidv7(), uuid_send(uuidv7()), $1, '{}', 'Passkey test' FROM generate_series(1, 100)", + user.as_uuid() ) - .bind(user.as_uuid()) .execute(&pool) .await .expect("100 passkeys"); @@ -80,11 +82,11 @@ async fn accounts_keep_at_most_100_passkeys() { ), "a 101st passkey" ); - sqlx::query( + sqlx::query!( "UPDATE passkey_credentials SET revoked_at = now() WHERE id = (SELECT id FROM passkey_credentials WHERE user_id = $1 LIMIT 1)", + user.as_uuid() ) - .bind(user.as_uuid()) .execute(&pool) .await .expect("revoke one"); diff --git a/crates/database/src/repositories/tests.rs b/crates/database/src/repositories/tests.rs index d36b873ca..f91cf6de8 100644 --- a/crates/database/src/repositories/tests.rs +++ b/crates/database/src/repositories/tests.rs @@ -14,12 +14,12 @@ async fn undecodable_columns_are_invalid_stored_data() { // Unique across runs: a v7's bytes with the version bits set to 4. let v4 = uuid::Builder::from_random_bytes(*uuid::Uuid::now_v7().as_bytes()).into_uuid(); let handle = Handle::parse(&format!("v4-{}", &v4.simple().to_string()[20..])).expect("handle"); - sqlx::query( + sqlx::query!( "WITH account AS (INSERT INTO users(id,display_name) VALUES($1,'Decode test')) INSERT INTO handles(handle,user_id) VALUES($2,$1)", + v4, + handle.as_str() ) - .bind(v4) - .bind(handle.as_str()) .execute(&pool) .await .expect("user with a v4 id"); @@ -32,17 +32,15 @@ async fn undecodable_columns_are_invalid_stored_data() { let user = UserId::new(); let session = SessionId::new(); - sqlx::query("INSERT INTO users(id,display_name) VALUES($1,'Decode test')") - .bind(user.as_uuid()) - .execute(&pool) - .await - .expect("user"); - sqlx::query( - "INSERT INTO sessions(id,user_id,authentication_methods,authenticated_at,expires_at,last_seen_at) - VALUES($1,$2,'[\"unknown\"]',now(),now()+interval '1 day',now())", + sqlx::query!( + "INSERT INTO users(id,display_name) VALUES($1,'Decode test')", + user.as_uuid() ) - .bind(session.as_uuid()) - .bind(user.as_uuid()) + .execute(&pool) + .await + .expect("user"); + sqlx::query!("INSERT INTO sessions(id,user_id,authentication_methods,authenticated_at,expires_at,last_seen_at) + VALUES($1,$2,'[\"unknown\"]',now(),now()+interval '1 day',now())", session.as_uuid(), user.as_uuid()) .execute(&pool) .await .expect("session with an unknown method"); diff --git a/crates/database/src/repositories/tokens/tests.rs b/crates/database/src/repositories/tokens/tests.rs index c65bb2d71..61e9563ac 100644 --- a/crates/database/src/repositories/tokens/tests.rs +++ b/crates/database/src/repositories/tokens/tests.rs @@ -25,21 +25,21 @@ async fn client(pool: &PgPool) -> ClientId { let client: ClientId = format!("locks_{}", UserId::new()) .parse() .expect("client ID"); - sqlx::query( + sqlx::query!( "INSERT INTO oidc_clients ( id, display_name, allowed_scopes, allowed_audiences, allow_refresh ) VALUES ($1, 'Lock test', '[\"openid\"]', '[\"test\"]', true)", + client.as_str() ) - .bind(client.as_str()) .execute(pool) .await .expect("client"); - sqlx::query( + sqlx::query!( "INSERT INTO oidc_redirect_uris (client_id, uri, kind, origin) VALUES ($1, $2, 'authorization', 'https://client.example')", + client.as_str(), + REDIRECT_URI ) - .bind(client.as_str()) - .bind(REDIRECT_URI) .execute(pool) .await .expect("redirect"); @@ -97,20 +97,20 @@ impl Grant { code: TokenId::new(), code_digest: TokenId::new().as_uuid().as_bytes().repeat(2), }; - sqlx::query( + sqlx::query!( "INSERT INTO authorization_codes ( id, secret_digest, client_id, user_id, session_id, redirect_uri, pkce_challenge, scopes, audience, expires_at, authentication, digest_key ) VALUES ($1, $2, $3, $4, $5, $6, 'challenge', '[\"openid\"]', 'test', now() + interval '1 minute', $7, 'test')", + grant.code.as_uuid(), + &grant.code_digest, + client.as_str(), + grant.user.as_uuid(), + grant.session.as_uuid(), + REDIRECT_URI, + serde_json::to_value(authentication()).expect("authentication") ) - .bind(grant.code.as_uuid()) - .bind(&grant.code_digest) - .bind(client.as_str()) - .bind(grant.user.as_uuid()) - .bind(grant.session.as_uuid()) - .bind(REDIRECT_URI) - .bind(sqlx::types::Json(authentication())) .execute(&mut *tx) .await .expect("code"); @@ -197,11 +197,13 @@ async fn independent_refreshes_share_client_and_logout_does_not_deadlock() { second_tx.rollback().await.expect("rollback"); let mut logout = pool.begin().await.expect("logout transaction"); - sqlx::query("UPDATE sessions SET revoked_at=now() WHERE id=$1") - .bind(grant.session.as_uuid()) - .execute(&mut *logout) - .await - .expect("lock session"); + sqlx::query!( + "UPDATE sessions SET revoked_at=now() WHERE id=$1", + grant.session.as_uuid() + ) + .execute(&mut *logout) + .await + .expect("lock session"); let mut rotation = pool.begin().await.expect("rotation transaction"); let rotation_backend = Database::backend(&mut rotation).await; let rotation_task = tokio::spawn(async move { @@ -247,17 +249,21 @@ async fn replay_revokes_family_despite_invalid_scopes() { .await .family(&mut TokenRepository::from_pool(&pool), &client) .await; - for statement in [ + sqlx::query!( "UPDATE refresh_tokens SET consumed_at=now() WHERE id=$1", + token.as_uuid(), + ) + .execute(&pool) + .await + .expect("consumed token"); + sqlx::query!( "UPDATE refresh_token_families SET scopes='[1]' WHERE id=(SELECT family_id FROM refresh_tokens WHERE id=$1)", - ] { - sqlx::query(statement) - .bind(token.as_uuid()) - .execute(&pool) - .await - .expect("consumed token with invalid scopes"); - } + token.as_uuid(), + ) + .execute(&pool) + .await + .expect("invalid scopes"); let mut tx = pool.begin().await.expect("transaction"); let result = TokenRepository::from_connection(&mut tx) .redeem_refresh( @@ -306,36 +312,44 @@ async fn a_kept_token_writes_nothing_and_holds_its_locks_until_commit() { // Whether another transaction can take each lock a refresh needs exclusively. let available = async || { let mut free = Vec::new(); - for (statement, id) in [ - ( - "SELECT 1 FROM users WHERE id = $1 FOR NO KEY UPDATE NOWAIT", - grant.user.as_uuid(), - ), - ( - "SELECT 1 FROM sessions WHERE id = $1 FOR UPDATE NOWAIT", - grant.session.as_uuid(), - ), - ( - "SELECT 1 FROM refresh_token_families WHERE id = $1 FOR UPDATE NOWAIT", - family.as_uuid(), - ), - ] { + for lock in 0..3 { let mut probe = pool.begin().await.expect("probe"); - free.push( - match sqlx::query(statement).bind(id).execute(&mut *probe).await { - Ok(_) => true, - Err(error) - if error - .as_database_error() - .and_then(sqlx::error::DatabaseError::code) - .as_deref() - == Some("55P03") => - { - false - } - Err(error) => panic!("probe: {error}"), - }, - ); + let attempt = match lock { + 0 => sqlx::query!( + r#"SELECT 1 AS "one!" FROM users WHERE id = $1 FOR NO KEY UPDATE NOWAIT"#, + grant.user.as_uuid(), + ) + .fetch_all(&mut *probe) + .await + .map(|_| ()), + 1 => sqlx::query!( + r#"SELECT 1 AS "one!" FROM sessions WHERE id = $1 FOR UPDATE NOWAIT"#, + grant.session.as_uuid(), + ) + .fetch_all(&mut *probe) + .await + .map(|_| ()), + _ => sqlx::query!( + r#"SELECT 1 AS "one!" FROM refresh_token_families WHERE id = $1 FOR UPDATE NOWAIT"#, + family.as_uuid(), + ) + .fetch_all(&mut *probe) + .await + .map(|_| ()), + }; + free.push(match attempt { + Ok(()) => true, + Err(error) + if error + .as_database_error() + .and_then(sqlx::error::DatabaseError::code) + .as_deref() + == Some("55P03") => + { + false + } + Err(error) => panic!("probe: {error}"), + }); probe.rollback().await.expect("rollback probe"); } free @@ -507,11 +521,13 @@ async fn code_replay_waits_for_first_redemption_and_revokes_its_family() { .expect("first redemption"); let (token, digest) = grant.family(&mut first.tokens(), &client).await; if !redeemable { - sqlx::query("DELETE FROM oidc_redirect_uris WHERE client_id = $1") - .bind(client.as_str()) - .execute(&pool) - .await - .expect("remove redirect URI"); + sqlx::query!( + "DELETE FROM oidc_redirect_uris WHERE client_id = $1", + client.as_str() + ) + .execute(&pool) + .await + .expect("remove redirect URI"); } let mut replay = DatabaseTransaction::new(pool.begin().await.expect("replay")); let replay_backend = Database::backend(&mut replay.inner).await; @@ -600,14 +616,14 @@ async fn session_revocation_ends_its_families_and_only_its_owners() { let mine = Grant::new(&pool, &client).await; let theirs = Grant::new(&pool, &client).await; let expired = SessionId::new(); - sqlx::query( + sqlx::query!( "INSERT INTO sessions ( id, user_id, authentication_methods, authenticated_at, expires_at, last_seen_at ) VALUES ($1, $2, '[]', now() - interval '2 hours', now() - interval '1 hour', now() - interval '2 hours')", + expired.as_uuid(), + mine.user.as_uuid() ) - .bind(expired.as_uuid()) - .bind(mine.user.as_uuid()) .execute(&pool) .await .expect("expired session"); @@ -700,10 +716,10 @@ async fn removal_expires_codes_an_earlier_exchange_still_sees_live() { let pool = Database::test_pool().await; let client = client(&pool).await; let grant = Grant::new(&pool, &client).await; - sqlx::query( + sqlx::query!( "UPDATE authorization_codes SET expires_at = now() + interval '1 second' WHERE id = $1", + grant.code.as_uuid() ) - .bind(grant.code.as_uuid()) .execute(&pool) .await .expect("expire soon"); diff --git a/crates/database/src/repositories/users/tests.rs b/crates/database/src/repositories/users/tests.rs index 570ac4388..26888f307 100644 --- a/crates/database/src/repositories/users/tests.rs +++ b/crates/database/src/repositories/users/tests.rs @@ -12,13 +12,13 @@ use std::{net::IpAddr, time::Duration}; /// Inserts a passkey row, which references the account through a foreign key. async fn insert_reference(connection: &mut sqlx::PgConnection, user: UserId) { - sqlx::query( + sqlx::query!( "INSERT INTO passkey_credentials(id,credential_id,user_id,credential,friendly_name) VALUES($1,$2,$3,'{}','Lock test')", + uuid::Uuid::now_v7(), + uuid::Uuid::now_v7().as_bytes().to_vec(), + user.as_uuid() ) - .bind(uuid::Uuid::now_v7()) - .bind(uuid::Uuid::now_v7().as_bytes().to_vec()) - .bind(user.as_uuid()) .execute(connection) .await .expect("reference"); @@ -67,13 +67,13 @@ async fn account_locks_do_not_wait_on_foreign_key_checks() { .expect("session"); tokio::time::timeout( Duration::from_secs(2), - sqlx::query( + sqlx::query!( "INSERT INTO user_emails (id, user_id, normalized_email, verified_at) VALUES ($1, $2, $3, now())", + uuid::Uuid::now_v7(), + user.as_uuid(), + format!("{user}@example.com") ) - .bind(uuid::Uuid::now_v7()) - .bind(user.as_uuid()) - .bind(format!("{user}@example.com")) .execute(&mut *account), ) .await @@ -146,12 +146,14 @@ async fn touch_records_activity_at_most_once_per_interval() { "a fresh session is not written" ); - sqlx::query("UPDATE sessions SET last_seen_at = $2 WHERE id = $1") - .bind(session.id.as_uuid()) - .bind(Utc::now() - LAST_SEEN_INTERVAL - chrono::Duration::seconds(1)) - .execute(pool) - .await - .expect("age session"); + sqlx::query!( + "UPDATE sessions SET last_seen_at = $2 WHERE id = $1", + session.id.as_uuid(), + Utc::now() - LAST_SEEN_INTERVAL - chrono::Duration::seconds(1) + ) + .execute(pool) + .await + .expect("age session"); sessions.touch(session.id, elsewhere).await.expect("touch"); let (at, ip) = last_seen(session.id).await; assert!(at > session.last_seen_at); diff --git a/crates/database/tests/recoveries.rs b/crates/database/tests/recoveries.rs index df9ab0cc7..43ec234c0 100644 --- a/crates/database/tests/recoveries.rs +++ b/crates/database/tests/recoveries.rs @@ -51,23 +51,25 @@ impl Owner { /// Makes recovery `id`'s unused link expire now. async fn expire(&self, id: RecoveryId) { - sqlx::query("UPDATE account_recoveries SET expires_at = clock_timestamp() WHERE id = $1") - .bind(id.as_uuid()) - .execute(&self.pool) - .await - .expect("expire"); + sqlx::query!( + "UPDATE account_recoveries SET expires_at = clock_timestamp() WHERE id = $1", + id.as_uuid() + ) + .execute(&self.pool) + .await + .expect("expire"); } /// Ends recovery `id`'s probation now, as if its link had been used /// [`PROBATION`] ago. async fn settle(&self, id: RecoveryId) { - sqlx::query( + sqlx::query!( "UPDATE account_recoveries SET completed_at = completed_at - interval '15 days', settles_at = clock_timestamp() WHERE id = $1", + id.as_uuid() ) - .bind(id.as_uuid()) .execute(&self.pool) .await .expect("settle");