Executar SQL não funciona no psql

Estou tentando executar:

SELECT user_id, 0 post_id, current_timestamp granted_at 
FROM badge_posts  
WHERE (:backfill OR user_id IN (:user_ids) OR 0 NOT IN (:post_ids) )
GROUP BY user_id 
HAVING count(*) > 1000

mas estou recebendo um erro em :backfill. Alguém pode me dizer o motivo?

Sei que esse SQL costumava funcionar na criação de medalhas.

Anything starting with a : is a named parameter meant to be replaced by mini_sql prior to being sent to the DBMS, it’s not valid SQL by itself.

Example, see [2] below:

[1] pry(main)> User.find_by(username: 'anon43915857').id
=> 5

[2] pry(main)> DB.query(
  "SELECT id FROM users WHERE username = :username",
  { username: 'anon43915857' }
).first.id
=> 5

[3] pry(main)> DB.query(
  "SELECT id FROM users WHERE username = ?",
  'anon43915857' 
).first.id
=> 5
3 curtidas

Thank you. This is clear.

1 curtida

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.