From 1896a96fc25510de848e7516fcf6bf449d902216 Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Thu, 18 Apr 2024 12:11:47 +0530 Subject: [PATCH] Use binders for setting parameters in `SQLCodeMigrations` --- .../database/migrations/SQLCodeMigrations.kt | 63 ++++++++++++------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/database/migrations/SQLCodeMigrations.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/database/migrations/SQLCodeMigrations.kt index 4faf115c0..90614bb76 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/database/migrations/SQLCodeMigrations.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/database/migrations/SQLCodeMigrations.kt @@ -47,30 +47,42 @@ object SQLCodeMigrations { val newFeedId = nameBasedUuidOf(oldFeedId).toString() driver.execute( identifier = null, - sql = "UPDATE feed SET id = '$newFeedId' WHERE id = '$oldFeedId'", - parameters = 0, - binders = null + sql = "UPDATE feed SET id = ? WHERE id = ?", + parameters = 2, + binders = { + bindString(0, newFeedId) + bindString(1, oldFeedId) + } ) driver.execute( identifier = null, - sql = "UPDATE feed_search SET id = '$newFeedId' WHERE id = '$oldFeedId'", - parameters = 0, - binders = null + sql = "UPDATE feed_search SET id = ? WHERE id = ?", + parameters = 2, + binders = { + bindString(0, newFeedId) + bindString(1, oldFeedId) + } ) driver.execute( identifier = null, - sql = "UPDATE bookmark SET sourceId = '$newFeedId' WHERE sourceId = '$oldFeedId'", - parameters = 0, - binders = null + sql = "UPDATE bookmark SET sourceId = ? WHERE sourceId = ?", + parameters = 2, + binders = { + bindString(0, newFeedId) + bindString(1, oldFeedId) + } ) driver.execute( identifier = null, - sql = "UPDATE post SET sourceId = '$newFeedId' WHERE sourceId = '$oldFeedId'", - parameters = 0, - binders = null + sql = "UPDATE post SET sourceId = ? WHERE sourceId = ?", + parameters = 2, + binders = { + bindString(0, newFeedId) + bindString(1, oldFeedId) + } ) } @@ -78,23 +90,32 @@ object SQLCodeMigrations { val newPostId = nameBasedUuidOf(oldPostId).toString() driver.execute( identifier = null, - sql = "UPDATE bookmark SET id = '$newPostId' WHERE id = '$oldPostId'", - parameters = 0, - binders = null + sql = "UPDATE bookmark SET id = ? WHERE id = ?", + parameters = 2, + binders = { + bindString(0, newPostId) + bindString(1, oldPostId) + } ) driver.execute( identifier = null, - sql = "UPDATE post_search SET id = '$newPostId' WHERE id = '$oldPostId'", - parameters = 0, - binders = null + sql = "UPDATE post_search SET id = ? WHERE id = ?", + parameters = 2, + binders = { + bindString(0, newPostId) + bindString(1, oldPostId) + } ) driver.execute( identifier = null, - sql = "UPDATE post SET id = '$newPostId' WHERE id = '$oldPostId'", - parameters = 0, - binders = null + sql = "UPDATE post SET id = ? WHERE id = ?", + parameters = 2, + binders = { + bindString(0, newPostId) + bindString(1, oldPostId) + } ) } }