Add test for legacy literal expression function

This commit is contained in:
Gwendal Roué committed 2020-02-25 22:18:16 +01:00
1 parent eb6f6e57ff
commit bad8d85729
1 file changed
+16 -1
+16 -1
View File
@@ -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'
""")
}
}
}
}