mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
Add test for legacy literal expression function
This commit is contained in:
1 parent
eb6f6e57ff
commit
bad8d85729
1 file changed
+16
-1
@@ -475,7 +475,8 @@ extension SQLLiteralTests {
|
||||
}
|
||||
|
||||
do {
|
||||
// Here we test that users can define functions that return literal expressions
|
||||
// Here we test that users can define functions that return
|
||||
// literal expressions.
|
||||
func date(_ value: SQLExpressible) -> SQLExpression {
|
||||
SQLLiteral("DATE(\(value))").sqlExpression
|
||||
}
|
||||
@@ -485,6 +486,20 @@ extension SQLLiteralTests {
|
||||
SELECT * FROM "player" WHERE (DATE("createdAt")) = '2020-01-23'
|
||||
""")
|
||||
}
|
||||
|
||||
do {
|
||||
// Here we test that users can still define functions that
|
||||
// return literal expressions with the previously
|
||||
// supported technique.
|
||||
func date(_ value: SQLExpressible) -> SQLExpression {
|
||||
SQLLiteral("DATE(\(value.sqlExpression))").sqlExpression
|
||||
}
|
||||
let createdAt = Column("createdAt")
|
||||
let request = Player.filter(date(createdAt) == "2020-01-23")
|
||||
try assertEqualSQL(db, request, """
|
||||
SELECT * FROM "player" WHERE (DATE("createdAt")) = '2020-01-23'
|
||||
""")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user