fix: ignore insert if a Starchart instance is already known

This commit is contained in:
Aravinth Manivannan 2023-02-28 16:37:22 +05:30
parent 83175b333a
commit 28bef1623f
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 26 additions and 6 deletions

View file

@ -258,15 +258,23 @@
},
"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)"
},
"7f61c8a9befb15076c783601325de9f761bec88e726243a323714ebb645d8f0e": {
"96e6de65010251e364c654901cd627a9ce25e98cf0277b10e97fec36ed6db25c": {
"describe": {
"columns": [],
"nullable": [],
"columns": [
{
"name": "instance_url",
"ordinal": 0,
"type_info": "Text"
}
],
"nullable": [
false
],
"parameters": {
"Right": 1
"Right": 2
}
},
"query": "INSERT INTO starchart_introducer (instance_url) VALUES ($1);"
"query": "SELECT\n instance_url\n FROM\n starchart_introducer\n LIMIT $1 OFFSET $2;\n "
},
"989fdcfc0088ac19ffbe29bba5349d2dcade134fa2b450769ec617d91f88ffe1": {
"describe": {
@ -522,6 +530,16 @@
},
"query": " DELETE 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)"
},
"efefccb1c7c44cecb34a6b2548662715695d7c07cea06a23090b3b0c0a21d1e2": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Right": 1
}
},
"query": "INSERT OR IGNORE INTO\n starchart_introducer (instance_url)\n VALUES ($1);"
},
"f162b8469f951609e5fa026fa14b074361a4c206b34a8e6ed048d2e54157f4bb": {
"describe": {
"columns": [

View file

@ -823,7 +823,9 @@ impl SCDatabase for Database {
async fn add_starchart_to_introducer(&self, url: &Url) -> DBResult<()> {
let url = url.as_str();
sqlx::query!(
"INSERT INTO starchart_introducer (instance_url) VALUES ($1);",
"INSERT OR IGNORE INTO
starchart_introducer (instance_url)
VALUES ($1);",
url
)
.execute(&self.pool)