Commit 03a31b9
authored
FEAT: Using Row Objects in MacOS Cursor (#81)
### 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]](diffhunk://#diff-4b626c1fe80240df798a2254710c9d104782e717f6c23e1268fc369906bf8c46R15)
[[2]](diffhunk://#diff-4b626c1fe80240df798a2254710c9d104782e717f6c23e1268fc369906bf8c46L36-R39)
[[3]](diffhunk://#diff-4b626c1fe80240df798a2254710c9d104782e717f6c23e1268fc369906bf8c46L654-R722).
### 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](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/37748)
### Checklist
- [x] **Tests Passed** (if applicable)
- [x] **Code is formatted**
- [x] **Docs Updated** (if necessary)
### Testing Performed
<!-- How was this fix tested? -->
- [x] Unit Tests1 parent 1d5f970 commit 03a31b9
1 file changed
+40
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
651 | 652 | | |
652 | 653 | | |
653 | 654 | | |
654 | | - | |
| 655 | + | |
655 | 656 | | |
656 | 657 | | |
657 | | - | |
| 658 | + | |
658 | 659 | | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
| 660 | + | |
663 | 661 | | |
664 | 662 | | |
665 | 663 | | |
666 | | - | |
667 | | - | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
668 | 667 | | |
669 | | - | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
670 | 674 | | |
671 | | - | |
| 675 | + | |
672 | 676 | | |
673 | 677 | | |
674 | | - | |
| 678 | + | |
675 | 679 | | |
676 | 680 | | |
677 | | - | |
| 681 | + | |
678 | 682 | | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
| 683 | + | |
683 | 684 | | |
684 | 685 | | |
685 | 686 | | |
686 | 687 | | |
687 | 688 | | |
688 | 689 | | |
689 | | - | |
690 | | - | |
691 | | - | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
692 | 696 | | |
| 697 | + | |
693 | 698 | | |
694 | 699 | | |
695 | | - | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
696 | 703 | | |
697 | | - | |
| 704 | + | |
698 | 705 | | |
699 | 706 | | |
700 | | - | |
| 707 | + | |
701 | 708 | | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
| 709 | + | |
706 | 710 | | |
707 | 711 | | |
708 | 712 | | |
709 | | - | |
710 | | - | |
711 | | - | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
712 | 716 | | |
| 717 | + | |
713 | 718 | | |
714 | 719 | | |
715 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
716 | 723 | | |
717 | 724 | | |
718 | 725 | | |
| |||
0 commit comments