fix dump script for n-m relations

n-m relations are dumped if either of the ids are inside the dumped
range, not only if both are in the dumped range.