Fix query error with PG