FEAT: Row string-key indexing #589
Open
jahnvi480 wants to merge 11 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restores/extends Row usability by allowing row["ColumnName"] access (in addition to positional and attribute access), addressing the regression reported in #582.
Changes:
- Updated
Row.__getitem__to accept string keys that map to column names. - Added unit and integration tests covering string-key access and expected error behavior.
- Added a test intending to cover case-insensitive string-key lookup when lowercase mode is enabled.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| mssql_python/row.py | Adds string-key handling to Row.__getitem__ (including an intended case-insensitive path). |
| tests/test_001_globals.py | Adds unit tests for string-key indexing and a case-insensitive variant. |
| tests/test_004_cursor.py | Adds an integration test verifying string-key indexing against real query results. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.build._deps.simdutf-src.src.haswell.implementation.cpp: 0.4%
mssql_python.pybind.build._deps.simdutf-src.src.implementation.cpp: 6.7%
mssql_python.pybind.build._deps.simdutf-src.include.simdutf.implementation.h: 10.4%
mssql_python.pybind.build._deps.simdutf-src.include.simdutf.scalar.utf16_to_utf8.utf16_to_utf8.h: 25.3%
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 59.7%
mssql_python.pybind.build._deps.simdutf-src.include.simdutf.internal.isadetection.h: 65.3%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 74.2%
mssql_python.__init__.py: 77.3%🔗 Quick Links
|
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 enhances the usability of the
Rowclass by allowing access to row values using column names as string keys (e.g.,row["col"]), in addition to existing integer index and attribute access. It also introduces case-insensitive string-key access when the cursor'slowercaseattribute is enabled. Comprehensive tests have been added to ensure correct behavior for these new access patterns.Enhancements to Row Access Patterns
Row.__getitem__method inmssql_python/row.pyto support accessing values by column name as a string key, including case-insensitive lookup when the cursor'slowercaseattribute is set.Testing Additions
test_row_string_key_indexingandtest_row_string_key_case_insensitive_with_lowercasetotests/test_001_globals.pyto verify string-key and case-insensitive access, as well as backward compatibility with integer and slice access.test_row_string_key_indexingtotests/test_004_cursor.pyto test string-key access on real query results, ensuring consistency with index and attribute access and correct error handling for missing keys.