Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mssql_python/pybind/param_detect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ inline void ApplyInputSizeOverride(PyObject* params, PyObject* inputSize, Py_ssi
}

info.isDAE =
(PyUnicode_Check(obj) && PyLongGreaterThan(columnSize, MAX_INLINE_CHAR)) ||
(PyUnicode_Check(obj) && info.columnSize > MAX_INLINE_CHAR) ||
((PyBytes_Check(obj) || PyByteArray_Check(obj)) &&
PyLongGreaterThan(columnSize, MAX_INLINE_BINARY));
info.columnSize > MAX_INLINE_BINARY);

if (PyTime_Check(obj) && info.paramCType == PARAM_C_TYPE_TEXT) {
NormalizeTimeParam(params, index, info.columnSize);
Expand Down
13 changes: 12 additions & 1 deletion tests/test_023_execute_path_parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,19 @@ def test_setinputsizes_binary_dae(cursor):
cursor.setinputsizes(None)


def test_setinputsizes_character_dae(cursor):
"""Declared character sizes over 4000 stream through the native DAE path."""
value = "x" * 5000
cursor.setinputsizes([(ddbc_sql_const.SQL_LONGVARCHAR.value, len(value), 0)])
try:
cursor.execute("SELECT LEN(CAST(? AS VARCHAR(MAX)))", [value])
assert cursor.fetchone()[0] == len(value)
finally:
cursor.setinputsizes(None)


def test_setinputsizes_numeric_precision_and_scale_are_clamped(cursor):
"""Oversized numeric metadata is clamped before narrowing to ODBC types."""
"""Clamped numeric metadata must not make short Decimal text use DAE."""
value = decimal.Decimal("0.1")
cursor.setinputsizes([(ddbc_sql_const.SQL_DECIMAL.value, 10**100, 10**100)])
try:
Expand Down
Loading