Skip to content

VARBINARY conversion error when passing a NULL #458

@amachanic

Description

@amachanic

Describe the bug

When passing a NULL to a VARBINARY column for insert, an error occurs rather than the correct behavor.

To reproduce

import mssql_python

conn = mssql_python.connect([conn string], autocommit=True)
cur = conn.cursor()
cur.execute('create table bytestest (b varbinary(50));')

cur.execute('insert into bytestest values (?)', None)

Exception message:

ProgrammingError: Driver Error: Syntax error or access violation; DDBC Error: [Microsoft][SQL Server]Implicit conversion from data type varchar to varbinary is not allowed. Use the CONVERT function to run this query.

Expected behavior

The None should be inserted as a NULL and I should see no error about VARCHAR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage neededFor new issues, not triaged yet.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions