Make whois commands case-insensitive

This commit is contained in:
Aadi Desai 2023-09-25 21:31:12 +01:00
parent 69e7a5a4f4
commit 89a9d2b085
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
3 changed files with 16 additions and 12 deletions

View file

@ -1,6 +1,6 @@
{ {
"db_name": "PostgreSQL", "db_name": "PostgreSQL",
"query": "select * from members where realname=$1", "query": "select * from members where lower(nickname)=lower($1)",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -42,5 +42,5 @@
false false
] ]
}, },
"hash": "56f54bfdc63d7c09add2bb4dec1e6a4544a684611755bcf2fa9424702ecd11cf" "hash": "00f839a86be2867afbb09fbbd0b940914bc63425c15ea3d156b437944d0e2247"
} }

View file

@ -1,6 +1,6 @@
{ {
"db_name": "PostgreSQL", "db_name": "PostgreSQL",
"query": "select * from members where nickname=$1", "query": "select * from members where lower(realname)=lower($1)",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -42,5 +42,5 @@
false false
] ]
}, },
"hash": "87fdce1d94c71a23196d11d87fbc748cb4c9ef59333f546da68b52322bd104c2" "hash": "de27ac619959b8f39424b8c4c46044377c40bc92785dddf927dba6d26bea522b"
} }

View file

@ -55,11 +55,13 @@ pub(crate) async fn get_member_by_nickname(
pool: &sqlx::PgPool, pool: &sqlx::PgPool,
nickname: &str, nickname: &str,
) -> Result<Option<Member>, Error> { ) -> Result<Option<Member>, Error> {
Ok( Ok(sqlx::query_as!(
sqlx::query_as!(Member, "select * from members where nickname=$1", nickname) Member,
.fetch_optional(pool) "select * from members where lower(nickname)=lower($1)",
.await?, nickname
) )
.fetch_optional(pool)
.await?)
} }
/// Get member entry by Real Name /// Get member entry by Real Name
@ -67,11 +69,13 @@ pub(crate) async fn get_member_by_realname(
pool: &sqlx::PgPool, pool: &sqlx::PgPool,
realname: &str, realname: &str,
) -> Result<Option<Member>, Error> { ) -> Result<Option<Member>, Error> {
Ok( Ok(sqlx::query_as!(
sqlx::query_as!(Member, "select * from members where realname=$1", realname) Member,
.fetch_optional(pool) "select * from members where lower(realname)=lower($1)",
.await?, realname
) )
.fetch_optional(pool)
.await?)
} }
/// Add member entry to members table /// Add member entry to members table