Skip to content

Conversation

@gargsaumya
Copy link
Contributor

@gargsaumya gargsaumya commented Nov 20, 2025

Work Item / Issue Reference

AB#40543

GitHub Issue: #333


Summary

This pull request introduces an error handling improvement to the fetchall method in mssql_python/cursor.py. The change ensures that errors from the fetch operation are properly checked and handled.

Error handling enhancement:

  • Added a call to check_error after fetching data in the fetchall method to verify and handle any errors returned by DDBCSQLFetchAll.

Copilot AI review requested due to automatic review settings November 20, 2025 05:58
@github-actions github-actions bot added the pr-size: small Minimal code update label Nov 20, 2025
@gargsaumya gargsaumya self-assigned this Nov 20, 2025
Copy link
Contributor

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

This pull request fixes GitHub Issue #333, which addresses a bug where fetchall() does not properly raise IntegrityError when executing INSERT statements with OUTPUT clauses that violate integrity constraints. The fix adds error checking after the fetch operation to ensure errors are properly detected and raised.

Key Changes:

  • Added check_error() call after DDBCSQLFetchAll() in the fetchall() method to properly handle and raise errors returned by the fetch operation
  • This brings fetchall() into consistency with other DDBC binding calls throughout the codebase that use check_error() for error handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Nov 21, 2025

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

75%


📈 Total Lines Covered: 5092 out of 6749
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

  • mssql_python/cursor.py (100%)

Summary

  • Total: 2 lines
  • Missing: 0 lines
  • Coverage: 100%

📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.row.py: 66.2%
mssql_python.pybind.ddbc_bindings.cpp: 67.1%
mssql_python.helpers.py: 67.5%
mssql_python.pybind.connection.connection.cpp: 74.7%
mssql_python.pybind.ddbc_bindings.h: 76.9%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 79.6%
mssql_python.connection.py: 82.5%
mssql_python.cursor.py: 83.8%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

@gargsaumya gargsaumya force-pushed the saumya/integrity-error branch from 9f1f3cb to 4a0f5f6 Compare November 25, 2025 07:19
@gargsaumya gargsaumya force-pushed the saumya/integrity-error branch from 1168cd6 to 8273dcc Compare November 25, 2025 07:54
@subrata-ms subrata-ms self-requested a review November 26, 2025 09:31
@saurabh500
Copy link
Contributor

Considering the fix is for making sure that the errors are thrown in fetch* API, a test should be added to validate this behavior.

Copy link
Contributor

@saurabh500 saurabh500 left a comment

Choose a reason for hiding this comment

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

Need tests for conditions where the silent failure is now avoided

@gargsaumya gargsaumya force-pushed the saumya/integrity-error branch from befc9ef to b1b70f4 Compare November 28, 2025 08:38
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: small Minimal code update labels Nov 28, 2025
@gargsaumya gargsaumya force-pushed the saumya/integrity-error branch from 87c4059 to e91baeb Compare November 28, 2025 08:47
@github-actions github-actions bot added pr-size: small Minimal code update and removed pr-size: medium Moderate update size labels Nov 28, 2025
@gargsaumya gargsaumya force-pushed the saumya/integrity-error branch 2 times, most recently from 4aa4445 to cce66f0 Compare November 28, 2025 09:24
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: small Minimal code update labels Nov 28, 2025
@gargsaumya gargsaumya force-pushed the saumya/integrity-error branch from 62636b2 to 237d0b5 Compare November 28, 2025 09:30
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.

As discussed, please resolve this PR and add new issues for other fetch* apis on GH and corresponding bugs in ADO. Please label the GH issues appropriately.

@gargsaumya gargsaumya dismissed saurabh500’s stale review November 28, 2025 12:16

Added the requested test. For the other fetch APIs, the return-code checks will be added in an upcoming PR that also fixes an issue we’ve identified in those APIs.

Thanks.

@gargsaumya gargsaumya merged commit b47a5cf into main Nov 28, 2025
27 checks passed
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.

6 participants