Conversation
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
mssql_python/pybind/connection/connection.cppLines 222-231 222 // Limit static buffer growth for memory safety
223 constexpr size_t MAX_BUFFER_COUNT = 100;
224 if (wstr_buffers.size() >= MAX_BUFFER_COUNT) {
225 // Remove oldest 50% of entries when limit reached
! 226 wstr_buffers.erase(wstr_buffers.begin(),
! 227 wstr_buffers.begin() + (MAX_BUFFER_COUNT / 2));
228 }
229
230 wstr_buffers.push_back(wstr);Lines 258-267 258 LOG("Set string attribute successfully");
259 }
260 return ret;
261 } catch (const std::exception& e) {
! 262 LOG("Exception during string attribute setting: " +
! 263 std::string(e.what()));
264 return SQL_ERROR;
265 }
266 } else if (py::isinstance<py::bytes>(value) ||
267 py::isinstance<py::bytearray>(value)) {Lines 272-281 272 // Limit static buffer growth
273 constexpr size_t MAX_BUFFER_COUNT = 100;
274 if (buffers.size() >= MAX_BUFFER_COUNT) {
275 // Remove oldest 50% of entries when limit reached
! 276 buffers.erase(buffers.begin(),
! 277 buffers.begin() + (MAX_BUFFER_COUNT / 2));
278 }
279
280 buffers.emplace_back(std::move(binary_data));
281 SQLPOINTER ptr = const_cast<char*>(buffers.back().c_str());Lines 290-299 290 LOG("Set attribute successfully with binary data");
291 }
292 return ret;
293 } catch (const std::exception& e) {
! 294 LOG("Exception during binary attribute setting: " +
! 295 std::string(e.what()));
296 return SQL_ERROR;
297 }
298 } else {
299 LOG("Unsupported attribute value type");mssql_python/pybind/connection/connection_pool.cppLines 58-67 58 valid_conn = std::make_shared<Connection>(connStr, true);
59 valid_conn->connect(attrs_before);
60 ++_current_size;
61 } else if (!valid_conn) {
! 62 throw std::runtime_error(
! 63 "ConnectionPool::acquire: pool size limit reached");
64 }
65 }
66
67 // Phase 3: Disconnect expired/bad connections outside lockLines 99-108 99 for (auto& conn : to_close) {
100 try {
101 conn->disconnect();
102 } catch (const std::exception& ex) {
! 103 LOG("ConnectionPool::close: disconnect failed: {}",
! 104 ex.what());
105 }
106 }
107 }mssql_python/pybind/unix_buffers.h📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.ddbc_bindings.cpp: 70.7%
mssql_python.row.py: 77.9%
mssql_python.pybind.connection.connection_pool.cpp: 78.9%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection.cpp: 81.2%
mssql_python.connection.py: 82.9%
mssql_python.cursor.py: 83.6%
mssql_python.auth.py: 87.1%
mssql_python.pooling.py: 87.7%
mssql_python.exceptions.py: 92.1%🔗 Quick Links
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request applies C++ linting and code style improvements to the connection implementation files in the mssql_python/pybind/connection directory. The changes focus on code readability, maintainability, and type safety without altering functional behavior.
Key changes include:
- Reformatted long function calls and statements across multiple lines for improved readability with consistent indentation
- Enhanced type safety by replacing
long longwithint64_tand usingreinterpret_castfor pointer conversions - Improved error handling with more descriptive error messages and robust exception handling
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| mssql_python/pybind/connection/connection.h | Updated include statements and reformatted function signatures for consistency |
| mssql_python/pybind/connection/connection.cpp | Extensive formatting improvements including line splitting, type safety enhancements, and improved error handling throughout |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
gargsaumya
previously approved these changes
Oct 27, 2025
Contributor
gargsaumya
left a comment
There was a problem hiding this comment.
LGTM. The added comments are non-blocking.
… jahnvi/code_linting_cpp
gargsaumya
approved these changes
Oct 27, 2025
bewithgaurav
approved these changes
Oct 28, 2025
gargsaumya
pushed a commit
that referenced
this pull request
Nov 3, 2025
### 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#38478](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/38478) ------------------------------------------------------------------- ### Summary This pull request refactors the `connection.cpp` and `connection.h` files to improve code readability, maintainability, and consistency, while also making minor corrections and clarifications to comments. The changes mainly involve formatting, type usage, and error handling improvements, as well as updating include paths and constructor signatures. **Code Formatting and Readability Improvements** * Reformatted function calls and argument lists for better readability, including breaking up long lines and grouping parameters logically in methods such as `getEnvHandle`, `allocateDbcHandle`, `commit`, `rollback`, and others in `connection.cpp`. * Improved comment formatting and clarity, including updating TODOs and explanatory comments to be more precise and easier to understand. **Type and Variable Usage Updates** * Updated integer types in `setAttribute` from `long long` to `int64_t` for clarity and platform consistency. * Improved buffer management for string and binary attributes by clarifying buffer lifetime logic and using more explicit type casts. **Error Handling Enhancements** * Enhanced error handling in attribute setting and connection attribute application, including more detailed error messages and fallback logic. **Include Path and Constructor Signature Updates** * Updated include paths in both `connection.cpp` and `connection.h` for consistency and to support future platform agnostic changes. * Modified the `ConnectionHandle` constructor signature to improve clarity and maintainability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
This pull request refactors the
connection.cppandconnection.hfiles to improve code readability, maintainability, and consistency, while also making minor corrections and clarifications to comments. The changes mainly involve formatting, type usage, and error handling improvements, as well as updating include paths and constructor signatures.Code Formatting and Readability Improvements
getEnvHandle,allocateDbcHandle,commit,rollback, and others inconnection.cpp.Type and Variable Usage Updates
setAttributefromlong longtoint64_tfor clarity and platform consistency.Error Handling Enhancements
Include Path and Constructor Signature Updates
connection.cppandconnection.hfor consistency and to support future platform agnostic changes.ConnectionHandleconstructor signature to improve clarity and maintainability.