Skip to content

Commit f5eb0e6

Browse files
committed
code coverage fix
1 parent 0ac41f9 commit f5eb0e6

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

mssql_python/pybind/ddbc_bindings.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,6 +3120,7 @@ SQLRETURN SQLGetData_wrap(SqlHandlePtr StatementHandle, SQLUSMALLINT colCount, p
31203120
} else if (dataLen == 0) {
31213121
row.append(py::str(""));
31223122
} else if (dataLen == SQL_NO_TOTAL) {
3123+
// LCOV_EXCL_START — defensive: driver controls indicator values
31233124
// SQL_NO_TOTAL means the driver has data but
31243125
// cannot report its total length. The buffer
31253126
// may contain a truncated prefix — fall back to
@@ -3131,6 +3132,7 @@ SQLRETURN SQLGetData_wrap(SqlHandlePtr StatementHandle, SQLUSMALLINT colCount, p
31313132
i);
31323133
row.append(FetchLobColumnData(hStmt, i, SQL_C_CHAR, false, false,
31333134
charEncoding));
3135+
// LCOV_EXCL_STOP
31343136
} else if (dataLen < 0) {
31353137
LOG("SQLGetData: Unexpected negative data length "
31363138
"for column %d - dataType=%d, dataLen=%ld",
@@ -3185,6 +3187,7 @@ SQLRETURN SQLGetData_wrap(SqlHandlePtr StatementHandle, SQLUSMALLINT colCount, p
31853187
} else if (dataLen == 0) {
31863188
row.append(py::str(""));
31873189
} else if (dataLen == SQL_NO_TOTAL) {
3190+
// LCOV_EXCL_START — defensive: driver controls indicator values
31883191
// SQL_NO_TOTAL means the driver has data but
31893192
// cannot report its total length. The buffer
31903193
// may contain a truncated prefix — fall back to
@@ -3196,6 +3199,7 @@ SQLRETURN SQLGetData_wrap(SqlHandlePtr StatementHandle, SQLUSMALLINT colCount, p
31963199
i);
31973200
row.append(
31983201
FetchLobColumnData(hStmt, i, SQL_C_WCHAR, true, false, "utf-16le"));
3202+
// LCOV_EXCL_STOP
31993203
} else if (dataLen < 0) {
32003204
LOG("SQLGetData: Unexpected negative data length "
32013205
"for column %d (VARCHAR via WCHAR) - dataLen=%ld",
@@ -3263,6 +3267,7 @@ SQLRETURN SQLGetData_wrap(SqlHandlePtr StatementHandle, SQLUSMALLINT colCount, p
32633267
} else if (dataLen == 0) {
32643268
row.append(py::str(""));
32653269
} else if (dataLen == SQL_NO_TOTAL) {
3270+
// LCOV_EXCL_START — defensive: driver controls indicator values
32663271
// SQL_NO_TOTAL means the driver has data but
32673272
// cannot report its total length. The buffer
32683273
// may contain a truncated prefix — fall back to
@@ -3274,6 +3279,7 @@ SQLRETURN SQLGetData_wrap(SqlHandlePtr StatementHandle, SQLUSMALLINT colCount, p
32743279
i);
32753280
row.append(
32763281
FetchLobColumnData(hStmt, i, SQL_C_WCHAR, true, false, "utf-16le"));
3282+
// LCOV_EXCL_STOP
32773283
} else if (dataLen < 0) {
32783284
LOG("SQLGetData: Unexpected negative data length "
32793285
"for column %d (NVARCHAR) - dataLen=%ld",
@@ -3993,11 +3999,16 @@ SQLRETURN FetchBatchData(SQLHSTMT hStmt, ColumnBuffers& buffers, py::list& colum
39933999
continue;
39944000
}
39954001
if (dataLen == SQL_NO_TOTAL) {
4002+
// LCOV_EXCL_START
39964003
// SQL_NO_TOTAL means the driver has data but cannot report
39974004
// its total length (common for variable-length columns).
39984005
// The bound buffer may contain a truncated prefix — fall
39994006
// back to LOB streaming to retrieve the full value instead
40004007
// of silently returning NULL.
4008+
//
4009+
// Coverage note: This branch is defensive — the ODBC driver
4010+
// controls indicator values in bound-column mode, so
4011+
// SQL_NO_TOTAL cannot be triggered from Python-level tests.
40014012
const ColumnInfoExt& noTotalColInfo = columnInfosExt[col - 1];
40024013
LOG("SQLGetData: SQL_NO_TOTAL for column %d (dataType=%d), "
40034014
"falling back to LOB streaming",
@@ -4049,6 +4060,7 @@ SQLRETURN FetchBatchData(SQLHSTMT hStmt, ColumnBuffers& buffers, py::list& colum
40494060
PyList_SET_ITEM(row, col - 1, Py_None);
40504061
break;
40514062
}
4063+
// LCOV_EXCL_STOP
40524064
continue;
40534065
}
40544066

0 commit comments

Comments
 (0)