Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send PLP_UNKNOWN for VARBINARY(MAX) too #132

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion src/pytds/tds_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,18 @@ def write(self, w, val):
if val is None:
w.put_uint8(tds_base.PLP_NULL)
else:
w.put_uint8(len(val))
# Putting the actual length here causes an error when bulk inserting:
#
# While reading current row from host, a premature end-of-message
# was encountered--an incoming data stream was interrupted when
# the server expected to see more data. The host program may have
# terminated. Ensure that you are using a supported client
# application programming interface (API).
#
# See https://github.com/tediousjs/tedious/issues/197
# It is not known why this happens, but Microsoft's bcp tool
# uses PLP_UNKNOWN for nvarchar(max) as well.
w.put_uint8(tds_base.PLP_UNKNOWN)
if val:
w.put_uint(len(val))
w.write(val)
Expand Down