3
1

Hi guys,

When posting a new question to my new installation of OSQA I'm getting the following error:

(-2147352567, 'Exception occurred.', (0, u'Microsoft OLE DB Provider for SQL Server', u"Cannot update identity column 'id'.", None, 0, -2147217900), None)

UPDATE [forum_node] SET [body] = ?, [last_activity_by_id] = ?, [last_activity_at] = ?, [title] = ?, [tagnames] = ?, [node_type] = ?, [active_revision_id] = ?, [id] = ? WHERE [forum_node].[id] IN (?)

I'm using the django-mssql provider, but I'm not sure the problem lies there. It seems for some reason the ORM is trying to update the id (with the same value it searches on).

Any ideas why this might be? as far as I can establish other routines work fine (such as creating new users). This is on the latest version in the trunk.

Thanks

asked 14 Sep '10, 15:43

James%20Crowley's gravatar image

James Crowley
41171315
accept rate: 40%

1

just tried using the mysql provider and that one seems to work fine? perhaps there's an issue with the way MySQL and SQL Server deal with identity columns? or is it just an issue with the django-mssql project>

(15 Sep '10, 13:40) James Crowley
1

I would file a bug report with the django-mssql project. We haven't done extensive testing with SQL Server, but our code should be relatively portable.

(19 Sep '10, 08:13) matt ♦♦

The link to the opened issue:

(22 Dec '10, 13:18) arc

I can't see the link ... hopefully this will work: http://code.google.com/p/django-mssql/issues/detail?id=90 ... if not: it's simply ID 90 ;-)

(06 Jan '11, 12:29) jashan

Is this still relevant? How about opening a bug in jira.osqa.net? (I know it might not be an OSQA issue, but I think it's important to have this documented as a bug, because it affects OSQA users).

(19 Mar '11, 11:11) ripper234 ♦

@ripper234 Yes, this issue is still relevant. It doesn't look like anything has been done with issue 90 in django-mssql

(06 Dec '11, 16:51) HAL9000
showing 5 of 6 show 1 more comments

I'm very new to both Python and Django. Please correct me or offer suggestions if there is a better way, but I was able to work around this by patching _get_update_kwargs() in forum/models/base.py.

Original

def _get_update_kwargs(self):
        return dict([
            (f.name, getattr(self, f.name)) for f in self._meta.fields if self._original_state[f.attname] != self.__dict__[f.attname]
        ])

Patched

def _get_update_kwargs(self):
    return dict([
        (f.name, getattr(self, f.name)) for f in self._meta.fields if self._original_state[f.attname] != self.__dict__[f.attname] and type(f) is not models.AutoField
    ])
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
link

answered 06 Dec '11, 17:47

HAL9000's gravatar image

HAL9000
6648
accept rate: 0%

edited 05 Jan, 16:15

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×25
×4
×1

Asked: 14 Sep '10, 15:43

Seen: 1,691 times

Last updated: 05 Jan, 16:15

powered by OSQA