Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query syntax when isActive = true #118

Merged
merged 1 commit into from
May 28, 2024
Merged

Conversation

lenguyenthanh
Copy link
Owner

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".

@lenguyenthanh lenguyenthanh merged commit d1ed6eb into main May 28, 2024
3 checks passed
@lenguyenthanh lenguyenthanh deleted the fix-query-syntax branch May 28, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant