Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix query syntax when isActive = true (#118)
`ServerInternalError` was thrown for this ``` curl -X 'GET' \ 'http://localhost:9669/api/players?sort_by=standard&order_by=desc&is_active=true&name=magnus%20carlsen&page=1&page_size=30' \ -H 'accept: application/json' ``` with stacktrace: ``` [info] π₯ [info] π₯ Postgres ERROR 42601 raised in scanner_yyerror (scan.l:1241) [info] π₯ [info] π₯ Problem: Syntax error at or near "AND". [info] π₯ [info] π₯ The statement under consideration was defined [info] π₯ at /Users/tle/git/lichess/fide/modules/db/src/main/scala/Db.scala:262 [info] π₯ [info] π₯ SELECT p.id, p.name, p.title, p.women_title, p.other_titles, p.standard, p.rapid, p.blitz, p.sex, p.birth_year, p.active, p.updated_at, p.created_at, f.id, f.name [info] π₯ FROM players AS p LEFT JOIN federations AS f ON p.federation_id = f.id [info] π₯ WHERE [info] π₯ AND p.active = $1 [info] π₯ ββββ Syntax error at or near "AND". [info] π₯ ORDER BY p.birth_year ASC NULLS LAST [info] π₯ LIMIT $2 OFFSET $3 [info] π₯ [info] π₯ If this is an error you wish to trap and handle in your application, you can do [info] π₯ so with a SqlState extractor. For example: [info] π₯ [info] π₯ doSomething.recoverWith { case SqlState.SyntaxError(ex) => ...} [info] π₯ [info] skunk.exception.PostgresErrorException: Syntax error at or near "AND". ```
- Loading branch information