Skip to content

Commit

Permalink
Encoding SQL type wasn't used when passing parameter.
Browse files Browse the repository at this point in the history
The encoding itself was used, but the ctype was hardcoded to SQL_WVARCHAR.

Fixes #195
  • Loading branch information
mkleehammer committed Feb 17, 2017
1 parent 92bf0ee commit 45f473b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ static bool GetUnicodeInfo(Cursor* cur, Py_ssize_t index, PyObject* param, Param

if (maxlength == 0 || cb <= maxlength)
{
info.ParameterType = SQL_WVARCHAR;
info.ParameterType = (enc.ctype == SQL_C_CHAR) ? SQL_VARCHAR : SQL_WVARCHAR;
info.ParameterValuePtr = PyBytes_AS_STRING(info.pObject);
info.BufferLength = (SQLINTEGER)cb;
info.StrLen_or_Ind = (SQLINTEGER)cb;
}
else
{
// Too long to pass all at once, so we'll provide the data at execute.
info.ParameterType = SQL_WLONGVARCHAR;
info.ParameterType = (enc.ctype == SQL_C_CHAR) ? SQL_LONGVARCHAR : SQL_WLONGVARCHAR;
info.ParameterValuePtr = &info;
info.BufferLength = sizeof(ParamInfo*);
info.StrLen_or_Ind = cur->cnxn->need_long_data_len ? SQL_LEN_DATA_AT_EXEC((SQLINTEGER)cb) : SQL_DATA_AT_EXEC;
Expand Down

0 comments on commit 45f473b

Please sign in to comment.