mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Test that DateTime is lexically comparable to CURRENT_TIMESTAMP
This commit is contained in:
1 parent
a8b97276e7
commit
aee04e0b72
1 file changed
+15
-2
@@ -31,11 +31,11 @@ class DateTimeTests : GRDBTestCase {
|
||||
super.setUp()
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
migrator.registerMigration("createStuffs") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE stuffs (" +
|
||||
"ID INTEGER PRIMARY KEY, " +
|
||||
"creationDate TEXT" +
|
||||
"creationDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP" +
|
||||
")")
|
||||
}
|
||||
assertNoError {
|
||||
@@ -91,4 +91,17 @@ class DateTimeTests : GRDBTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testDateTimeIsLexicallyComparableToCURRENT_TIMESTAMP() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute("INSERT INTO stuffs (id, creationDate) VALUES (?,?)", arguments: [1, DateTime(NSDate().dateByAddingTimeInterval(-1))])
|
||||
try db.execute("INSERT INTO stuffs (id) VALUES (?)", arguments: [2])
|
||||
try db.execute("INSERT INTO stuffs (id, creationDate) VALUES (?,?)", arguments: [3, DateTime(NSDate().dateByAddingTimeInterval(1))])
|
||||
|
||||
let ids = db.fetchAll(Int.self, "SELECT id FROM stuffs ORDER BY creationDate").map { $0! }
|
||||
XCTAssertEqual(ids, [1,2,3])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user