PostgreSQL not returning original query in query_format method