Skip to content

Conversation

jahnvi480
Copy link
Contributor

@jahnvi480 jahnvi480 commented Aug 14, 2025

Work Item / Issue Reference

AB#34924


Summary

This pull request introduces a new convenience method, skip, to the Cursor class in mssql_python/cursor.py, which allows users to advance the cursor position by a specified number of rows without fetching them. Comprehensive tests have been added to validate the method's behavior, including edge cases and integration with existing fetch methods.

New feature: Cursor skipping

  • Added skip(count: int) method to the Cursor class, enabling users to efficiently advance the cursor by a given number of rows without returning those rows. The method checks for closed cursors, validates arguments, supports no-op for zero, and raises appropriate errors for invalid usage.

Testing and validation

  • Added test_cursor_skip_basic_functionality to verify that skip advances the cursor as expected and integrates correctly with fetchone.
  • Added tests for edge cases: skipping zero rows (test_cursor_skip_zero_is_noop), empty result sets (test_cursor_skip_empty_result_set), skipping past the end (test_cursor_skip_past_end), invalid arguments (test_cursor_skip_invalid_arguments), and closed cursors (test_cursor_skip_closed_cursor).
  • Added integration tests to ensure skip works correctly with fetchone, fetchmany, and fetchall methods (test_cursor_skip_integration_with_fetch_methods).

@github-actions github-actions bot added the pr-size: medium Moderate update size label Aug 14, 2025
Copy link
Contributor

@gargsaumya gargsaumya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since skip() is just an alias for scroll(count, 'relative'), it carries the same inefficiency concerns for large skips. Approving for now.

Copy link
Contributor

@sumitmsft sumitmsft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the changes to the logic of PR# 180 as this PR depends on it. Let's hold on to it for now.

@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 25, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Aug 25, 2025
@jahnvi480 jahnvi480 requested a review from sumitmsft August 25, 2025 09:50
@jahnvi480
Copy link
Contributor Author

@sumitmsft @gargsaumya Resolved comments in #180 Please have a look at it and let me know if there are any other changes required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-size: medium Moderate update size
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants