diff --git a/.sqlx/query-792037c2586baeca11fc16c3c7cfcdd1e0d75a2ca085749d0483f098443597ac.json b/.sqlx/query-063224c6636d76faf35fc7f83743419900ac8259d238c07772afc3f3f8c18a7d.json similarity index 79% rename from .sqlx/query-792037c2586baeca11fc16c3c7cfcdd1e0d75a2ca085749d0483f098443597ac.json rename to .sqlx/query-063224c6636d76faf35fc7f83743419900ac8259d238c07772afc3f3f8c18a7d.json index abdc9c3..483ca9a 100644 --- a/.sqlx/query-792037c2586baeca11fc16c3c7cfcdd1e0d75a2ca085749d0483f098443597ac.json +++ b/.sqlx/query-063224c6636d76faf35fc7f83743419900ac8259d238c07772afc3f3f8c18a7d.json @@ -1,6 +1,6 @@ { "db_name": "SQLite", - "query": "\n SELECT id, verification_time as \"verification_time: NaiveDateTime\"\n FROM candidates\n WHERE id = $1\n ", + "query": "\n SELECT id, verification_time as \"verification_time: NaiveDateTime\"\n FROM candidates\n WHERE id = $1 COLLATE NOCASE\n ", "describe": { "columns": [ { @@ -22,5 +22,5 @@ true ] }, - "hash": "792037c2586baeca11fc16c3c7cfcdd1e0d75a2ca085749d0483f098443597ac" + "hash": "063224c6636d76faf35fc7f83743419900ac8259d238c07772afc3f3f8c18a7d" } diff --git a/.sqlx/query-2ac323324a8ed9bc0296660bc56a96a58b1a6178a8c3e2f367c09a767b386693.json b/.sqlx/query-2ac323324a8ed9bc0296660bc56a96a58b1a6178a8c3e2f367c09a767b386693.json new file mode 100644 index 0000000..1055dc1 --- /dev/null +++ b/.sqlx/query-2ac323324a8ed9bc0296660bc56a96a58b1a6178a8c3e2f367c09a767b386693.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "DELETE FROM candidates WHERE id = $1 COLLATE NOCASE", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + }, + "hash": "2ac323324a8ed9bc0296660bc56a96a58b1a6178a8c3e2f367c09a767b386693" +} diff --git a/.sqlx/query-7cb2a9ac8a6605c2b8f83f0dcee78815bd6fc344c67adf98c6d76cbb72255d2e.json b/.sqlx/query-7cb2a9ac8a6605c2b8f83f0dcee78815bd6fc344c67adf98c6d76cbb72255d2e.json deleted file mode 100644 index 5b7f549..0000000 --- a/.sqlx/query-7cb2a9ac8a6605c2b8f83f0dcee78815bd6fc344c67adf98c6d76cbb72255d2e.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "DELETE FROM candidates WHERE id = $1", - "describe": { - "columns": [], - "parameters": { - "Right": 1 - }, - "nullable": [] - }, - "hash": "7cb2a9ac8a6605c2b8f83f0dcee78815bd6fc344c67adf98c6d76cbb72255d2e" -} diff --git a/.sqlx/query-32dc384f62c4d22190e05c9c9144a0d101d9fc6e6de889e2e4bded8415ec0170.json b/.sqlx/query-8d15558bfe57d80116c5bbabc9c0eee2b21e92c062ae760decc2abd74f32871e.json similarity index 56% rename from .sqlx/query-32dc384f62c4d22190e05c9c9144a0d101d9fc6e6de889e2e4bded8415ec0170.json rename to .sqlx/query-8d15558bfe57d80116c5bbabc9c0eee2b21e92c062ae760decc2abd74f32871e.json index 79944c1..466075e 100644 --- a/.sqlx/query-32dc384f62c4d22190e05c9c9144a0d101d9fc6e6de889e2e4bded8415ec0170.json +++ b/.sqlx/query-8d15558bfe57d80116c5bbabc9c0eee2b21e92c062ae760decc2abd74f32871e.json @@ -1,6 +1,6 @@ { "db_name": "SQLite", - "query": "\n UPDATE candidates\n SET verification_time = $2\n WHERE id = $1\n ", + "query": "\n UPDATE candidates\n SET verification_time = $2\n WHERE id = $1 COLLATE NOCASE\n ", "describe": { "columns": [], "parameters": { @@ -8,5 +8,5 @@ }, "nullable": [] }, - "hash": "32dc384f62c4d22190e05c9c9144a0d101d9fc6e6de889e2e4bded8415ec0170" + "hash": "8d15558bfe57d80116c5bbabc9c0eee2b21e92c062ae760decc2abd74f32871e" } diff --git a/migrations/20251129150553_compare_case_insensitive.down.sql b/migrations/20251129150553_compare_case_insensitive.down.sql new file mode 100644 index 0000000..04b4d39 --- /dev/null +++ b/migrations/20251129150553_compare_case_insensitive.down.sql @@ -0,0 +1 @@ +DROP INDEX idx_candidates_id_nocase diff --git a/migrations/20251129150553_compare_case_insensitive.up.sql b/migrations/20251129150553_compare_case_insensitive.up.sql new file mode 100644 index 0000000..25c978f --- /dev/null +++ b/migrations/20251129150553_compare_case_insensitive.up.sql @@ -0,0 +1 @@ +CREATE INDEX idx_candidates_id_nocase ON candidates(id COLLATE NOCASE); diff --git a/src/database/candidate.rs b/src/database/candidate.rs index 61cced4..a04cf12 100644 --- a/src/database/candidate.rs +++ b/src/database/candidate.rs @@ -26,7 +26,7 @@ pub async fn get(id: &str, executor: impl SqliteExecutor<'_>) -> Result) -> Result<()> { r#" UPDATE candidates SET verification_time = $2 - WHERE id = $1 + WHERE id = $1 COLLATE NOCASE "#, id, now @@ -55,7 +55,7 @@ pub async fn verify(id: &str, executor: impl SqliteExecutor<'_>) -> Result<()> { #[tracing::instrument(skip(executor))] pub async fn delete(id: &str, executor: impl SqliteExecutor<'_>) -> Result<()> { - sqlx::query!("DELETE FROM candidates WHERE id = $1", id) + sqlx::query!("DELETE FROM candidates WHERE id = $1 COLLATE NOCASE", id) .execute(executor) .await?;