google-code-export / django-pyodbc

Automatically exported from code.google.com/p/django-pyodbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Error adding model with null values when specifying the primary key #87

Open GoogleCodeExporter opened 9 years ago

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

Open the attached django project, run manage.py shell, and run through the 
below interactive console output.

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

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from borken_app.models import *
>>> BorkenTable.objects.create()
<BorkenTable: BorkenTable object>
>>> BorkenTable.objects.create(id=10)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "m:\a\obj\web_portal\python\lib\site-packages\django\db\models\manager.py", line 138, in create
    return self.get_query_set().create(**kwargs)
  File "m:\a\obj\web_portal\python\lib\site-packages\django\db\models\query.py", line 352, in create
    obj.save(force_insert=True, using=self.db)
  File "m:\a\obj\web_portal\python\lib\site-packages\django\db\models\base.py", line 435, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "m:\a\obj\web_portal\python\lib\site-packages\django\db\models\base.py", line 528, in save_base
    result = manager._insert(values, return_id=update_pk, using=using)
  File "m:\a\obj\web_portal\python\lib\site-packages\django\db\models\manager.py", line 195, in _insert
    return insert_query(self.model, values, **kwargs)
  File "m:\a\obj\web_portal\python\lib\site-packages\django\db\models\query.py", line 1479, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "m:\a\obj\web_portal\python\lib\site-packages\django\db\models\sql\compiler.py", line 783, in execute_sql
    cursor = super(SQLInsertCompiler, self).execute_sql(None)
  File "m:\a\obj\web_portal\python\lib\site-packages\django\db\models\sql\compiler.py", line 727, in execute_sql
    cursor.execute(sql, params)
  File "m:\a\obj\web_portal\python\lib\site-packages\django\db\backends\util.py", line 15, in execute
    return self.cursor.execute(sql, params)
  File "m:\a\obj\web_portal\python\lib\site-packages\sql_server\pyodbc\base.py", line 314, in execute
    return self.cursor.execute(sql, params)
Error: ('07009', '[07009] [Microsoft][ODBC SQL Server Driver]Invalid 
DescriptorIndex (0) (SQLDescribeParam); [07009] [Microsoft][ODBC SQL Server 
Driver]Invalid parameter number (0)')
>>> BorkenTable.objects.create(id=10, int=3, string="shoe")
<BorkenTable: BorkenTable object>
>>> BorkenTable.objects.create(int=3, string="shoe")
<BorkenTable: BorkenTable object>

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

Win7 x64 (using 32-bit python)
pyodbc 2.1.7

Please provide any additional information below.

Potentially related to an issue in pyodbc: 
http://groups.google.com/group/pyodbc/browse_thread/thread/f325e2ddbce4f043?pli=
1

Original issue reported on code.google.com by SheepN...@gmail.com on 20 Jul 2010 at 3:52

Attachments:

GoogleCodeExporter commented 9 years ago
Need patch pyodbc, please see the attached patch.

Original comment by vcc.ch...@gmail.com on 22 Jul 2010 at 6:02

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by vcc.ch...@gmail.com on 24 Mar 2011 at 4:58