Skip to content

Commit 14ae820

Browse files
authored
fix(DataStore): include table name inside quotes in SQL Update statement (#1824)
* fix(DataStore): include table name inside quotes in SQL Update statement * Include table name in quotes for alter and drop table statements
1 parent 42f98e0 commit 14ae820

File tree

7 files changed

+14
-12
lines changed

7 files changed

+14
-12
lines changed

AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Storage/SQLite/SQLStatement+AlterTable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct AlterTableStatement: SQLStatement {
1414
var modelSchema: ModelSchema
1515

1616
var stringValue: String {
17-
return "ALTER TABLE \(fromModelSchema.name) RENAME TO \(modelSchema.name)"
17+
return "ALTER TABLE \"\(fromModelSchema.name)\" RENAME TO \"\(modelSchema.name)\""
1818
}
1919

2020
init(from fromModelSchema: ModelSchema, toModelSchema: ModelSchema) {

AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Storage/SQLite/SQLStatement+DropTable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct DropTableStatement: SQLStatement {
1414
var modelSchema: ModelSchema
1515

1616
var stringValue: String {
17-
return "DROP TABLE IF EXISTS \(modelSchema.name)"
17+
return "DROP TABLE IF EXISTS \"\(modelSchema.name)\""
1818
}
1919

2020
init(modelSchema: ModelSchema) {

AmplifyPlugins/DataStore/AWSDataStoreCategoryPlugin/Storage/SQLite/SQLStatement+Update.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct UpdateStatement: SQLStatement {
3939
}
4040

4141
var sql = """
42-
update \(modelSchema.name)
42+
update "\(modelSchema.name)"
4343
set
4444
\(columnsStatement.joined(separator: ",\n"))
4545
where \(modelSchema.primaryKey.columnName()) = ?

AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginTests/Core/SQLStatementTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class SQLStatementTests: XCTestCase {
235235
let statement = UpdateStatement(model: post, modelSchema: post.schema)
236236

237237
let expectedStatement = """
238-
update Post
238+
update "Post"
239239
set
240240
"content" = ?,
241241
"createdAt" = ?,
@@ -266,7 +266,7 @@ class SQLStatementTests: XCTestCase {
266266
let statement = UpdateStatement(model: post, modelSchema: post.schema, condition: condition)
267267

268268
let expectedStatement = """
269-
update Post
269+
update "Post"
270270
set
271271
"content" = ?,
272272
"createdAt" = ?,

AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginTests/Migration/SQLiteMutationSyncMetadataMigrationDelegateTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ class SQLiteMutationSyncMetadataMigrationDelegateTests: MutationSyncMetadataMigr
120120
// Dropping the table without the table in the database is successful
121121
let drop = try delegate.removeMutationSyncMetadataCopyStore()
122122

123-
XCTAssertEqual(drop, "DROP TABLE IF EXISTS MutationSyncMetadataCopy")
123+
XCTAssertEqual(drop, """
124+
DROP TABLE IF EXISTS "MutationSyncMetadataCopy"
125+
""")
124126

125127
// Creating the table is successful
126128
let create = try delegate.createMutationSyncMetadataCopyStore()

AmplifyPlugins/DataStore/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ SPEC CHECKSUMS:
127127

128128
PODFILE CHECKSUM: 07ff9134d58a47ca475ed1439261458407a9b1f3
129129

130-
COCOAPODS: 1.11.3
130+
COCOAPODS: 1.11.2

Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- AWSCore (2.27.0)
2+
- AWSCore (2.27.9)
33
- CwlCatchException (2.1.1):
44
- CwlCatchExceptionSupport (~> 2.1.1)
55
- CwlCatchExceptionSupport (2.1.1)
@@ -10,7 +10,7 @@ PODS:
1010
- CwlMachBadInstructionHandler (~> 2.1.0)
1111
- CwlPosixPreconditionTesting (~> 2.1.0)
1212
- SwiftFormat/CLI (0.44.17)
13-
- SwiftLint (0.46.2)
13+
- SwiftLint (0.47.1)
1414

1515
DEPENDENCIES:
1616
- AWSCore (~> 2.27.0)
@@ -39,15 +39,15 @@ CHECKOUT OPTIONS:
3939
:tag: 2.1.0
4040

4141
SPEC CHECKSUMS:
42-
AWSCore: d605449939e5b40704f11ff9f91f905f7d978589
42+
AWSCore: 3419bcaeec8d7809efa32f0e83f151ef8e93ad78
4343
CwlCatchException: 86760545af2a490a23e964d76d7c77442dbce79b
4444
CwlCatchExceptionSupport: a004322095d7101b945442c86adc7cec0650f676
4545
CwlMachBadInstructionHandler: aa1fe9f2d08b29507c150d099434b2890247e7f8
4646
CwlPosixPreconditionTesting: 1ba4471964405941f79b3f06bbcf3c2be782950c
4747
CwlPreconditionTesting: 73ae5de517a8761e5e40fb4136c6a26365af0440
4848
SwiftFormat: 3b5caa6389b2b9adbc00e133b3ccc8c6e687a6a4
49-
SwiftLint: 6bc52a21f0fd44cab9aa2dc8e534fb9f5e3ec507
49+
SwiftLint: f80f1be7fa96d30e0aa68e58d45d4ea1ccaac519
5050

5151
PODFILE CHECKSUM: 5e20e56b8ef40444b018a3736b7b726ff9772f00
5252

53-
COCOAPODS: 1.11.3
53+
COCOAPODS: 1.11.2

0 commit comments

Comments
 (0)