[BZ-1072217] rewrite or constraints when necessary