Skip to content

Commit

Permalink
Another failing test for #514
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Apr 10, 2019
1 parent a6cbd24 commit 00ae2de
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Tests/GRDBTests/DatabaseRegionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -785,4 +785,49 @@ class DatabaseRegionTests : GRDBTestCase {
}
}
}

// Regression test
func testIssue514() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.write { db in
try db.execute(sql: """
CREATE TABLE a (id INTEGER PRIMARY KEY, name TEXT);
CREATE TABLE b (id TEXT, name TEXT);
""")

// INTEGER PRIMARY KEY
do {
let statement = try db.makeSelectStatement(sql: "SELECT id FROM a")
let expectedRegion = DatabaseRegion(table: "a", columns: ["id"])
XCTAssertEqual(statement.databaseRegion, expectedRegion)
}
do {
let statement = try db.makeSelectStatement(sql: "SELECT name FROM a")
let expectedRegion = DatabaseRegion(table: "a", columns: ["name"])
XCTAssertEqual(statement.databaseRegion, expectedRegion)
}
do {
let statement = try db.makeSelectStatement(sql: "SELECT id, name FROM a")
let expectedRegion = DatabaseRegion(table: "a", columns: ["id", "name"])
XCTAssertEqual(statement.databaseRegion, expectedRegion)
}

// TEXT primary key
do {
let statement = try db.makeSelectStatement(sql: "SELECT id FROM b")
let expectedRegion = DatabaseRegion(table: "b", columns: ["id"])
XCTAssertEqual(statement.databaseRegion, expectedRegion)
}
do {
let statement = try db.makeSelectStatement(sql: "SELECT name FROM b")
let expectedRegion = DatabaseRegion(table: "b", columns: ["name"])
XCTAssertEqual(statement.databaseRegion, expectedRegion)
}
do {
let statement = try db.makeSelectStatement(sql: "SELECT id, name FROM b")
let expectedRegion = DatabaseRegion(table: "b", columns: ["id", "name"])
XCTAssertEqual(statement.databaseRegion, expectedRegion)
}
}
}
}

0 comments on commit 00ae2de

Please sign in to comment.