Fixes limit problem on table.query (#1998)