feat: sqlite sqlx implementation for repository_exists
This commit is contained in:
parent
85aafb4b96
commit
2055a00565
2 changed files with 41 additions and 0 deletions
|
@ -54,6 +54,24 @@
|
||||||
},
|
},
|
||||||
"query": "SELECT ID FROM starchart_forge_type WHERE name = $1"
|
"query": "SELECT ID FROM starchart_forge_type WHERE name = $1"
|
||||||
},
|
},
|
||||||
|
"71079442588dfaece04582acdb14d2c8928c695d4eab5332d09b82cefc880d54": {
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "ID",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Int64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"query": "SELECT ID FROM starchart_repositories\n WHERE \n name = $1\n AND\n owner_id = ( SELECT ID FROM starchart_users WHERE username = $2)\n AND\n hostname_id = (SELECT ID FROM starchart_forges WHERE hostname = $3)"
|
||||||
|
},
|
||||||
"8c78e074d78291f9d3c4ef3526bae00cb356591edad79a7fb1f20aa7bb681216": {
|
"8c78e074d78291f9d3c4ef3526bae00cb356591edad79a7fb1f20aa7bb681216": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [],
|
"columns": [],
|
||||||
|
|
|
@ -218,6 +218,29 @@ impl SCDatabase for Database {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// check if a repo exists.
|
||||||
|
async fn repository_exists(&self, name: &str, owner: &str, hostname: &str) -> DBResult<bool> {
|
||||||
|
match sqlx::query!(
|
||||||
|
"SELECT ID FROM starchart_repositories
|
||||||
|
WHERE
|
||||||
|
name = $1
|
||||||
|
AND
|
||||||
|
owner_id = ( SELECT ID FROM starchart_users WHERE username = $2)
|
||||||
|
AND
|
||||||
|
hostname_id = (SELECT ID FROM starchart_forges WHERE hostname = $3)",
|
||||||
|
name,
|
||||||
|
owner,
|
||||||
|
hostname,
|
||||||
|
)
|
||||||
|
.fetch_one(&self.pool)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_) => Ok(true),
|
||||||
|
Err(Error::RowNotFound) => Ok(false),
|
||||||
|
Err(e) => Err(DBError::DBError(Box::new(e).into())),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn now_unix_time_stamp() -> i64 {
|
fn now_unix_time_stamp() -> i64 {
|
||||||
|
|
Loading…
Reference in a new issue