Commit 12245e8
authored
FIX: Execute returning cursor object (#161)
### Work Item / Issue Reference
<!--
IMPORTANT: Please follow the PR template guidelines below.
For mssql-python maintainers: Insert your ADO Work Item ID below (e.g.
AB#37452)
For external contributors: Insert Github Issue number below (e.g. #149)
Only one reference is required - either GitHub issue OR ADO Work Item.
-->
<!-- mssql-python maintainers: ADO Work Item -->
> AB#3806
-------------------------------------------------------------------
### Summary
This pull request enhances the `Cursor` class in
`mssql_python/cursor.py` to support method chaining by modifying the
`execute` method to return the cursor itself. It also introduces
comprehensive test coverage for method chaining in
`tests/test_004_cursor.py`.
### Enhancements to the `Cursor` class:
* Modified the `execute` method in `mssql_python/cursor.py` to return
the `Cursor` instance, enabling method chaining. (`[[1]]
### Updates to test cases:
* Simplified the `test_longwvarchar` test by removing unnecessary loops
and assertions, improving readability.
* Added new test cases to validate method chaining functionality,
including:
- Chaining `execute` with `fetchone`, `fetchall`, `fetchmany`,
`rowcount`, and `description`.
- Testing multiple sequential operations and parameterized queries.
- Ensuring chaining works correctly after errors and with statement
reuse for performance.
---------
Co-authored-by: Jahnvi Thakkar <jathakkar@microsoft.com>1 parent 365b712 commit 12245e8
File tree
6 files changed
+4344
-45
lines changed- mssql_python
- pybind
- tests
6 files changed
+4344
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
| |||
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
120 | 127 | | |
121 | 128 | | |
122 | 129 | | |
| |||
0 commit comments