2

如何将 WHERE x LIKE $xyz 添加到查询生成器?

我从

let searchQuery = try? request.query.get(String.self, at: "s")
...
query.where(\Talk.title, SwifQL.like(searchQuery))

但是接下来我要搜索不区分大小写的字符串我有错误:

[ ERROR ] PostgreSQLError.server.error.scanner_yyerror: GET /testroute?s=Swift syntax error at or near "$8" (ErrorMiddleware.swift:26)

4

1 回答 1

5

解决方案:

query.where((\Talk.title).iLike("%\(searchQuery ?? "x")%"))
于 2020-05-02T10:44:16.723 回答