mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
test for julianDay function
This commit is contained in:
1 parent
2aeddda77d
commit
59c5d2e43b
1 file changed
+13
@@ -256,4 +256,17 @@ class FoundationDateTests : GRDBTestCase {
|
||||
XCTAssertTrue(abs(calendar.component(.nanosecond, from: date) - 4_000_000) < 10) // We actually get 4_000_008. Some precision is lost during the DateComponents -> Date conversion. Not a big deal.
|
||||
}
|
||||
}
|
||||
|
||||
func testJulianDaySQLFunction() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute(
|
||||
sql: "INSERT INTO dates (creationDate) VALUES (?)",
|
||||
arguments: ["2013-01-01T00:29:59"])
|
||||
let expression = julianDay(Column("creationDate"))
|
||||
let request: SQLRequest<Double> = "SELECT \(expression) from dates"
|
||||
let double = try request.fetchOne(db)!
|
||||
XCTAssertEqual(double, 2456293.5208217595)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user