opt(sql): added 'LIMIT 1' to SELECT queries, that fetch only one item
This commit is contained in:
parent
1d1f4896a4
commit
33d4454c68
|
@ -19,7 +19,7 @@ impl Backend {
|
||||||
) -> anyhow::Result<anyhow::Result<Uuid, Error>> {
|
) -> anyhow::Result<anyhow::Result<Uuid, Error>> {
|
||||||
match sqlx::query_as!(
|
match sqlx::query_as!(
|
||||||
AuthTokensRow,
|
AuthTokensRow,
|
||||||
r#"SELECT * FROM AuthTokens WHERE token = ?;"#,
|
r#"SELECT * FROM AuthTokens WHERE token = ? LIMIT 1;"#,
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
.fetch_one(&self.pool)
|
.fetch_one(&self.pool)
|
||||||
|
@ -49,7 +49,7 @@ impl Backend {
|
||||||
) -> anyhow::Result<anyhow::Result<(), Error>> {
|
) -> anyhow::Result<anyhow::Result<(), Error>> {
|
||||||
match sqlx::query_as!(
|
match sqlx::query_as!(
|
||||||
InviteTokensRow,
|
InviteTokensRow,
|
||||||
r#"SELECT * FROM InviteTokens WHERE token = ?;"#,
|
r#"SELECT * FROM InviteTokens WHERE token = ? LIMIT 1;"#,
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
.fetch_one(&self.pool)
|
.fetch_one(&self.pool)
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl Backend {
|
||||||
async fn get_user(&self, userid: Uuid) -> Result<Result<User, Error>> {
|
async fn get_user(&self, userid: Uuid) -> Result<Result<User, Error>> {
|
||||||
match sqlx::query_as!(
|
match sqlx::query_as!(
|
||||||
UsersRow,
|
UsersRow,
|
||||||
r#"SELECT * FROM Users WHERE userid = ?;"#,
|
r#"SELECT * FROM Users WHERE userid = ? LIMIT 1;"#,
|
||||||
userid.as_bytes().as_slice()
|
userid.as_bytes().as_slice()
|
||||||
)
|
)
|
||||||
.fetch_one(&self.pool)
|
.fetch_one(&self.pool)
|
||||||
|
|
Loading…
Reference in New Issue