A few fixes for postgres and sqlite.