From 2938bba15a8ca70c26f716fda5239149df4cf542 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 25 May 2021 16:58:09 -0400 Subject: [PATCH] Support updating collection only with monetization_pointer --- database.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/database.go b/database.go index df300ce..e8cac92 100644 --- a/database.go +++ b/database.go @@ -875,7 +875,7 @@ func (db *datastore) UpdateCollection(c *SubmittedCollection, alias string) erro // WHERE values q.Where("alias = ? AND owner_id = ?", alias, c.OwnerID) - if q.Updates == "" { + if q.Updates == "" && c.Monetization == nil { return ErrPostNoUpdatableVals } @@ -932,10 +932,12 @@ func (db *datastore) UpdateCollection(c *SubmittedCollection, alias string) erro } // Update rest of the collection data - res, err = db.Exec("UPDATE collections SET "+q.Updates+" WHERE "+q.Conditions, q.Params...) - if err != nil { - log.Error("Unable to update collection: %v", err) - return err + if q.Updates != "" { + res, err = db.Exec("UPDATE collections SET "+q.Updates+" WHERE "+q.Conditions, q.Params...) + if err != nil { + log.Error("Unable to update collection: %v", err) + return err + } } rowsAffected, _ = res.RowsAffected()