Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not delete tags if none are provided on update #276

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions crate/server/src/database/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,18 +477,18 @@ pub(crate) async fn update_object_(
.execute(&mut **executor)
.await?;

// delete the existing tags
sqlx::query(
MYSQL_QUERIES
.get("delete-tags")
.ok_or_else(|| kms_error!("SQL query can't be found"))?,
)
.bind(uid)
.execute(&mut **executor)
.await?;

// Insert the new tags if any
if let Some(tags) = tags {
// delete the existing tags
sqlx::query(
MYSQL_QUERIES
.get("delete-tags")
.ok_or_else(|| kms_error!("SQL query can't be found"))?,
)
.bind(uid)
.execute(&mut **executor)
.await?;

for tag in tags {
sqlx::query(
MYSQL_QUERIES
Expand Down
22 changes: 11 additions & 11 deletions crate/server/src/database/pgsql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,18 +485,18 @@ pub(crate) async fn update_object_(
.execute(&mut **executor)
.await?;

// delete the existing tags
sqlx::query(
PGSQL_QUERIES
.get("delete-tags")
.ok_or_else(|| kms_error!("SQL query can't be found"))?,
)
.bind(uid)
.execute(&mut **executor)
.await?;

// Insert the new tags
// Update the tags
if let Some(tags) = tags {
// delete the existing tags
sqlx::query(
PGSQL_QUERIES
.get("delete-tags")
.ok_or_else(|| kms_error!("SQL query can't be found"))?,
)
.bind(uid)
.execute(&mut **executor)
.await?;

for tag in tags {
sqlx::query(
PGSQL_QUERIES
Expand Down
19 changes: 9 additions & 10 deletions crate/server/src/database/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,18 +491,17 @@ pub(crate) async fn update_object_(
.execute(&mut **executor)
.await?;

// delete the existing tags
sqlx::query(
SQLITE_QUERIES
.get("delete-tags")
.ok_or_else(|| kms_error!("SQL query can't be found"))?,
)
.bind(uid)
.execute(&mut **executor)
.await?;

// Insert the new tags if any
if let Some(tags) = tags {
// delete the existing tags
sqlx::query(
SQLITE_QUERIES
.get("delete-tags")
.ok_or_else(|| kms_error!("SQL query can't be found"))?,
)
.bind(uid)
.execute(&mut **executor)
.await?;
for tag in tags {
sqlx::query(
SQLITE_QUERIES
Expand Down
Loading