What every ‘?' in your SQL is hiding
Take a query that comes out of pg_stat_statements: SELECT date_trunc(?, o.created_at) AS week, count(*) AS total FROM orders o INNER JOIN customers c ON c.id = o.customer_id WHERE o.created_at >= ? AND o.amount > ? AND c.plan = ? GROUP BY ? ORDER BY 2 DESC LIMIT ? Six question marks. Each one means something completely different. The first, inside date_trunc, expects a string like 'week' — it's telling the function which time bucket to use. The second is a timestamp comparing against created_at. The third i
评论
?
参与讨论