From fc88acc7820ffc333793d911241cfd44d4cada3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 5 Oct 2017 13:55:51 +0200 Subject: [PATCH] Add failing test for "DROP TABLE t" executed from a prepared statement. --- Tests/GRDBTests/UpdateStatementTests.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/GRDBTests/UpdateStatementTests.swift b/Tests/GRDBTests/UpdateStatementTests.swift index 924fff181..b96ce3266 100644 --- a/Tests/GRDBTests/UpdateStatementTests.swift +++ b/Tests/GRDBTests/UpdateStatementTests.swift @@ -307,4 +307,20 @@ class UpdateStatementTests : GRDBTestCase { } } } + + func testDropTablePreparedStatement() throws { + // In v2.0.1... + let dbQueue = try makeDatabaseQueue() + try dbQueue.inDatabase { db in + XCTAssertFalse(try db.tableExists("t")) + try db.execute("CREATE TABLE t(a)") + XCTAssertTrue(try db.tableExists("t")) + try db.execute("DROP TABLE t") // ... this would drop the table + XCTAssertFalse(try db.tableExists("t")) + try db.execute("CREATE TABLE t(a)") + XCTAssertTrue(try db.tableExists("t")) + try db.makeUpdateStatement("DROP TABLE t").execute() // ... but this would not. WTF??? Hence this regression test. + XCTAssertFalse(try db.tableExists("t")) + } + } }