FEAT: datetimeoffset support in executemany() by gargsaumya ยท Pull Request #260 ยท microsoft/mssql-python

๐Ÿ“Š Code Coverage Report

๐Ÿ”ฅ Diff Coverage

85%


๐ŸŽฏ Overall Coverage

73%


๐Ÿ“ˆ Total Lines Covered: 4052 out of 5513
๐Ÿ“ Project: mssql-python


Diff Coverage

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

  • mssql_python/cursor.py (100%)
  • mssql_python/pybind/ddbc_bindings.cpp (85.5%): Missing lines 1950-1951,1954-1955,1959-1961,1986,3227-3228,3230

Summary

  • Total: 77 lines
  • Missing: 11 lines
  • Coverage: 85%

mssql_python/pybind/ddbc_bindings.cpp

Lines 1946-1965

  1946                     for (size_t i = 0; i < paramSetSize; ++i) {
  1947                         const py::handle& param = columnValues[i];
  1948 
  1949                         if (param.is_none()) {
! 1950                             std::memset(&dtoArray[i], 0, sizeof(DateTimeOffset));
! 1951                             strLenOrIndArray[i] = SQL_NULL_DATA;
  1952                         } else {
  1953                             if (!py::isinstance(param, datetimeType)) {
! 1954                                 ThrowStdException(MakeParamMismatchErrorStr(info.paramCType, paramIndex));
! 1955                             }
  1956 
  1957                             py::object tzinfo = param.attr("tzinfo");
  1958                             if (tzinfo.is_none()) {
! 1959                                 ThrowStdException("Datetime object must have tzinfo for SQL_C_SS_TIMESTAMPOFFSET at paramIndex " +
! 1960                                     std::to_string(paramIndex));
! 1961                             }
  1962 
  1963                             // Populate the C++ struct directly from the Python datetime object.
  1964                             dtoArray[i].year   = static_cast<SQLSMALLINT>(param.attr("year").cast<int>());
  1965                             dtoArray[i].month  = static_cast<SQLUSMALLINT>(param.attr("month").cast<int>());

Lines 1982-1990

  1982                     }
  1983                     dataPtr = dtoArray;
  1984                     bufferLength = sizeof(DateTimeOffset);
  1985                     break;
! 1986                 }
  1987                 case SQL_C_NUMERIC: {
  1988                     SQL_NUMERIC_STRUCT* numericArray = AllocateParamBufferArray<SQL_NUMERIC_STRUCT>(tempBuffers, paramSetSize);
  1989                     strLenOrIndArray = AllocateParamBufferArray<SQLLEN>(tempBuffers, paramSetSize);
  1990                     for (size_t i = 0; i < paramSetSize; ++i) {

Lines 3223-3234

  3223                         );
  3224                         py_dt = py_dt.attr("astimezone")(datetime.attr("timezone").attr("utc"));
  3225                         row.append(py_dt);
  3226                     } else {
! 3227                         row.append(py::none());
! 3228                     }
  3229                     break;
! 3230                 }
  3231                 case SQL_GUID: {
  3232                     SQLGUID* guidValue = &buffers.guidBuffers[col - 1][i];
  3233                     uint8_t reordered[16];
  3234                     reordered[0] = ((char*)&guidValue->Data1)[3];


๐Ÿ“‹ Files Needing Attention

๐Ÿ“‰ Files with overall lowest coverage (click to expand)
mssql_python.pybind.ddbc_bindings.cpp: 67.4%
mssql_python.pybind.connection.connection.cpp: 68.3%
mssql_python.ddbc_bindings.py: 68.5%
mssql_python.pybind.connection.connection_pool.cpp: 78.9%
mssql_python.cursor.py: 79.1%
mssql_python.connection.py: 81.7%
mssql_python.helpers.py: 84.7%
mssql_python.auth.py: 85.3%
mssql_python.type.py: 86.8%
mssql_python.pooling.py: 88.8%

๐Ÿ”— Quick Links