mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Test that sqlite authorizer uses "ROWID" as the name of the rowid column
This commit is contained in:
1 parent
fd65e72bbb
commit
1a89b2eae5
1 file changed
+57
-1
@@ -21,7 +21,26 @@ class StatementSelectionInfoTests : GRDBTestCase {
|
||||
XCTAssertTrue(statement.selectionInfo.contains(anyColumnIn: ["fooId"], from: "bar"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func testRowIdNameInSelectStatement() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE foo (name TEXT)")
|
||||
do {
|
||||
let statement = try db.makeSelectStatement("SELECT rowid FROM FOO")
|
||||
XCTAssertTrue(statement.selectionInfo.contains(anyColumnIn: ["ROWID"], from: "foo"))
|
||||
}
|
||||
do {
|
||||
let statement = try db.makeSelectStatement("SELECT _ROWID_ FROM FOO")
|
||||
XCTAssertTrue(statement.selectionInfo.contains(anyColumnIn: ["ROWID"], from: "foo"))
|
||||
}
|
||||
do {
|
||||
let statement = try db.makeSelectStatement("SELECT oID FROM FOO")
|
||||
XCTAssertTrue(statement.selectionInfo.contains(anyColumnIn: ["ROWID"], from: "foo"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateStatement() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.inDatabase { db in
|
||||
@@ -37,6 +56,43 @@ class StatementSelectionInfoTests : GRDBTestCase {
|
||||
XCTAssertEqual(columnNames, Set(["bar", "baz"]))
|
||||
}
|
||||
}
|
||||
|
||||
func testRowIdNameInUpdateStatement() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("CREATE TABLE foo (name TEXT)")
|
||||
do {
|
||||
let statement = try db.makeUpdateStatement("UPDATE foo SET rowid = 1")
|
||||
XCTAssertEqual(statement.databaseEventKinds.count, 1)
|
||||
guard case .update(let tableName, let columnNames) = statement.databaseEventKinds[0] else {
|
||||
XCTFail()
|
||||
return
|
||||
}
|
||||
XCTAssertEqual(tableName, "foo")
|
||||
XCTAssertEqual(columnNames, ["ROWID"])
|
||||
}
|
||||
do {
|
||||
let statement = try db.makeUpdateStatement("UPDATE foo SET _ROWID_ = 1")
|
||||
XCTAssertEqual(statement.databaseEventKinds.count, 1)
|
||||
guard case .update(let tableName, let columnNames) = statement.databaseEventKinds[0] else {
|
||||
XCTFail()
|
||||
return
|
||||
}
|
||||
XCTAssertEqual(tableName, "foo")
|
||||
XCTAssertEqual(columnNames, ["ROWID"])
|
||||
}
|
||||
do {
|
||||
let statement = try db.makeUpdateStatement("UPDATE foo SET oID = 1")
|
||||
XCTAssertEqual(statement.databaseEventKinds.count, 1)
|
||||
guard case .update(let tableName, let columnNames) = statement.databaseEventKinds[0] else {
|
||||
XCTFail()
|
||||
return
|
||||
}
|
||||
XCTAssertEqual(tableName, "foo")
|
||||
XCTAssertEqual(columnNames, ["ROWID"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testInsertStatement() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
|
||||
Reference in new issue
Block a user