Skip to content

Conversation

jahnvi480
Copy link
Contributor

@jahnvi480 jahnvi480 commented Aug 22, 2025

Work Item / Issue Reference

AB#34929
AB#34930


Summary

This pull request adds support for retrieving special columns from a database table using the ODBC SQLSpecialColumns function. The main changes include new methods in the Python cursor for accessing row identifier and version columns, as well as the necessary C++ and Python bindings to expose this ODBC functionality. Additionally, relevant constants have been added to support these features.

New Python cursor methods:

  • Added rowIdColumns and rowVerColumns methods to the Cursor class in mssql_python/cursor.py, allowing users to retrieve columns that uniquely identify a row (SQL_BEST_ROWID) and columns that are automatically updated when any value in the row is updated (SQL_ROWVER). These methods handle ODBC parameter preparation, call the new binding, and return results as row objects.

ODBC and pybind11 binding support:

  • Defined the SQLSpecialColumnsFunc function pointer type and added the corresponding global pointer in mssql_python/pybind/ddbc_bindings.h and mssql_python/pybind/ddbc_bindings.cpp.
  • Loaded the SQLSpecialColumnsW symbol from the ODBC driver in the driver loader, and included it in the function pointer validation check.
  • Implemented the SQLSpecialColumns_wrap function to call the ODBC API, handling both Unix and Windows string conversions, and exposed it to Python as DDBCSQLSpecialColumns in the module definition.

Constants:

  • Added new constants for SQL_SCOPE_CURROW, SQL_BEST_ROWID, SQL_ROWVER, SQL_NO_NULLS, and SQL_NULLABLE_UNKNOWN to the ConstantsDDBC enum in mssql_python/constants.py to support the new functionality.

@github-actions github-actions bot added the pr-size: large Substantial code update label Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-size: large Substantial code update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant