fix where clause for postgres