tanrj / pyodbc

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

Inserting into a nullable geometry column in SQL Server 2008 fails when the bind parameter is given as None #103

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a table with a nullable geometry column
CREATE TABLE spots (
    spot_id INTEGER NOT NULL IDENTITY(1,1), 
    spot_height NUMERIC(6, 2) NULL, 
        spot_location GEOMETRY NULL,
    PRIMARY KEY (spot_id)
)
2. 'INSERT INTO spots (spot_height, spot_location) OUTPUT inserted.spot_id 
VALUES (?, ?)' (420.39999999999998, None)

What is the expected output? What do you see instead?
The expected output is that the row with the NULL geometry is inserted into the 
database. Instead I get the following SQL Error:
"[22018] [Microsoft][ODBC SQL Server Driver][SQL Server]Operand type clash: 
image is incompatible with geometry (206) (SQLExecDirectW); [42000] 
[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be 
prepared. (8180)"

What version of the product are you using? On what operating system?
pyodbc-2.1.7
Windows XP SP 3
SQL Server 2008
SqlAlchemy 0.6.1

Please provide any additional information below.

I am using pyodbc via SqlAlchemy. If I change the bind parameter from None to 
an explicit 'NULL', then it works as expected.

Original issue reported on code.google.com by Mark.H...@mail.room3b.eu on 18 Jun 2010 at 9:16

GoogleCodeExporter commented 8 years ago
Fixed in 2.1.8.

Added unit test test_geometry_null_insert to sqlservertests.

Original comment by mkleehammer on 6 Sep 2010 at 5:34

GoogleCodeExporter commented 8 years ago

Original comment by mkleehammer on 21 Nov 2010 at 4:44