ruricolist / cl-yesql

Common Lisp library for using SQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Syntax error in WHERE IS

phoe opened this issue · comments

Query:

-- name: select-personas-of-player
-- Returns personas belonging to a given player. Only owned personas
-- are owned if the second argument is false; if true, borrowed
-- personas are included as well.
SELECT p.id, p.name, p.description, p.creation_time, p.last_edit_time
  FROM persona as p, players_personas AS g
  WHERE p.id = g.persona_id AND g.player_id = ?
        AND (g.is_owner IS TRUE OR g.is_owner IS ?);

Call:

(select-personas-of-player 1 nil)

Error:

Database error 42601: bd skadni w lub blisko "$2"
QUERY: SELECT p.id, p.name, p.description, p.creation_time, p.last_edit_time
  FROM persona as p, players_personas AS g
  WHERE p.id = g.persona_id AND g.player_id = $1
        AND (g.is_owner IS TRUE OR g.is_owner IS $2);

Worked around it by using = instead of IS.

SELECT p.id, p.name, p.description, p.creation_time, p.last_edit_time
  FROM persona as p, players_personas AS g
  WHERE p.id = g.persona_id AND g.player_id = ?
        AND (g.is_owner IS TRUE OR g.is_owner = ?);

Should this limitation be documented anywhere in CL-YESQL?

This seems like a Postgres problem, but I don't read Polish so I don't know what the error is saying. (Google Translate isn't helping.)

błąd składni w lub blisko "$2" means syntax error in or near "$2".

Google translate likely isn't helping you because of marijnh/Postmodern#191 .