Add constraint to query when schema as env attribute