djhenderson / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Exception when passing an untyped NULL as a param #129

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

import pyodbc
db = pyodbc.connect ("...")
q = db.cursor ()
q.execute ("SELECT ?", [None])
q.fetchall ()

What is the expected output? What do you see instead?

Expected: [(None,)]

Instead: pyodbc.Error: ('07009', '[07009] [Microsoft][ODBC SQL Server 
Driver]Invalid Descriptor Index (0) (SQLDescribeParam); [42000] [Micros
oft][ODBC SQL Server Driver]Syntax error or access violation (0)')

What version of the product are you using? On what operating system?

pyodbc 2.1.8 (strictly: a git clone) on Python 2.6 WinXP SP3 against MSSQL 2005

Please provide any additional information below.

This is a regression; the code used to work in pyodbc 2.0.x. The problem occurs 
when SQLDescribeParam is called within GetParamType in params.cpp. This is 
presumably because SQL Server can't determine a type for the parameter. 

The error code is unfortunately a fairly general one which would cover 
circumstances other than this so it's not possible simply to filter it out at 
this point. (Altho' the code does work if you ignore the error and return 
VARCHAR).

Original issue reported on code.google.com by tjgolden@gmail.com on 19 Oct 2010 at 1:48

GoogleCodeExporter commented 9 years ago
Fixed in 2.1.9-beta03

Original comment by mkleehammer on 21 Nov 2010 at 5:14