Skip to content

FEAT: Using Row Objects in MacOS Cursor #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 19, 2025

Conversation

bewithgaurav
Copy link
Collaborator

@bewithgaurav bewithgaurav commented Jun 18, 2025

Summary

This pull request refactors the Cursor class in mssql_python/cursor_mac.py to improve data handling by introducing a Row object for query results. The changes enhance type safety and make the interface more consistent by replacing raw sequences (e.g., tuples) with Row objects. Additionally, the implementation of fetchone, fetchmany, and fetchall methods has been updated to reflect this new design.

Refactoring for Improved Data Handling:

  • Introduction of Row Object: Added an import for the Row class and updated the fetchone, fetchmany, and fetchall methods to return Row objects instead of raw sequences like tuples. This change improves type safety and encapsulates row data with metadata (mssql_python/cursor_mac.py, [1] [2] [3].

Method Updates:

  • fetchone Method: Refactored to fetch raw data, check for no data, and return a Row object constructed with the row data and description.
  • fetchmany Method: Updated to fetch a specified number of rows, validate input size, and return a list of Row objects.
  • fetchall Method: Modified to fetch all remaining rows and return them as a list of Row objects.

Issue Reference

Fixes AB#37748

Checklist

  • Tests Passed (if applicable)
  • Code is formatted
  • Docs Updated (if necessary)

Testing Performed

  • Unit Tests

@Copilot Copilot AI review requested due to automatic review settings June 18, 2025 14:31
@bewithgaurav bewithgaurav changed the title FEAT: Row Class in Mac Cursor FEAT: Using Row Objects in Mac Cursor Jun 18, 2025
@bewithgaurav bewithgaurav changed the title FEAT: Using Row Objects in Mac Cursor FEAT: Using Row Objects in MacOS Cursor Jun 18, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors the Cursor class in cursor_mac.py to return Row objects instead of raw tuples for all fetch methods.

  • Added import of Row and updated docstrings to reflect new return types.
  • Reworked fetchone, fetchmany, and fetchall to wrap raw results in Row.
  • Adjusted error/data‐absence handling in each fetch method.
Comments suppressed due to low confidence (2)

mssql_python/cursor_mac.py:669

  • The module references ddbc_sql_const but it is not imported; this will cause a NameError. Please add the appropriate import for ddbc_sql_const.
        if ret == ddbc_sql_const.SQL_NO_DATA.value:

mssql_python/cursor_mac.py:718

  • The condition is inverted: it currently returns an empty list when rows are present and only converts when there is no data. It should be if ret == ddbc_sql_const.SQL_NO_DATA.value: to early-return on no data.
        if ret != ddbc_sql_const.SQL_NO_DATA.value:

@bewithgaurav bewithgaurav merged commit 03a31b9 into main Jun 19, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants