From 1e3e65bf4826c12e5fc1230f34b42d8c29d03aed Mon Sep 17 00:00:00 2001 From: seika1 Date: Sun, 9 Aug 2020 00:59:28 -0700 Subject: [PATCH] chuni: Fix upsert with an empty userRecentRating --- src/chunithm/sql/userRecentRating.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/chunithm/sql/userRecentRating.ts b/src/chunithm/sql/userRecentRating.ts index 156fb74..7c49605 100644 --- a/src/chunithm/sql/userRecentRating.ts +++ b/src/chunithm/sql/userRecentRating.ts @@ -34,6 +34,12 @@ export class SqlUserRecentRatingRepository profileId: Id, objs: UserRecentRatingItem[] ): Promise { + // Don't do anything if there's nothing to save, + // since trying to execute an empty insert statement fails. + if (objs.length === 0) { + return Promise.resolve(); + } + const stmt = sql .insert( "cm_user_recent_rating",