From 94f6363251772a28d61909d1342198c6d06babf6 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 25 Sep 2020 05:15:58 -0700 Subject: [PATCH] add LIMIT 1 to our updates, out of healthy fear This is just me thinking about what could go wrong in the modeling rollout, this at least makes it so that, if something breaks, it will break small --- src/server/query-tests/__snapshots__/Pet.test.js.snap | 6 +++--- src/server/types/Outfit.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/server/query-tests/__snapshots__/Pet.test.js.snap b/src/server/query-tests/__snapshots__/Pet.test.js.snap index 6e144a2..a3141b6 100644 --- a/src/server/query-tests/__snapshots__/Pet.test.js.snap +++ b/src/server/query-tests/__snapshots__/Pet.test.js.snap @@ -1035,7 +1035,7 @@ Array [ ], ], Array [ - "UPDATE items SET rarity_index = ?, thumbnail_url = ?, updated_at = ?, zones_restrict = ? WHERE id = ?;", + "UPDATE items SET rarity_index = ?, thumbnail_url = ?, updated_at = ?, zones_restrict = ? WHERE id = ? LIMIT 1;", Array [ 500, "http://images.neopets.com/items/mall_staff_jewelled.gif", @@ -1045,7 +1045,7 @@ Array [ ], ], Array [ - "UPDATE item_translations SET description = ?, name = ?, updated_at = ? WHERE item_id = ? AND locale = \\"en\\";", + "UPDATE item_translations SET description = ?, name = ?, updated_at = ? WHERE item_id = ? AND locale = \\"en\\" LIMIT 1;", Array [ "This jewelled staff shines with a magical light.", "Jewelled Staff", @@ -1466,7 +1466,7 @@ Array [ ], ], Array [ - "UPDATE swf_assets SET body_id = ? WHERE type = ? AND remote_id = ?;", + "UPDATE swf_assets SET body_id = ? WHERE type = ? AND remote_id = ? LIMIT 1;", Array [ "0", "object", diff --git a/src/server/types/Outfit.js b/src/server/types/Outfit.js index 7e2ab00..11f0200 100644 --- a/src/server/types/Outfit.js +++ b/src/server/types/Outfit.js @@ -488,10 +488,10 @@ async function syncToDb( const qs = columnNames.map((c) => `${c} = ?`).join(", "); const [conditionQs, ...conditionValues] = buildUpdateCondition(incomingRow); updatePromises.push( - db.execute(`UPDATE ${tableName} SET ${qs} WHERE ${conditionQs};`, [ - ...rowValues, - ...conditionValues, - ]) + db.execute( + `UPDATE ${tableName} SET ${qs} WHERE ${conditionQs} LIMIT 1;`, + [...rowValues, ...conditionValues] + ) ); } await Promise.all(updatePromises);