Skip to content

Commit

Permalink
Fixed issue #75, thanks SheepNine.
Browse files Browse the repository at this point in the history
  • Loading branch information
vcc@163.com committed Jul 22, 2010
1 parent 7dffddb commit 65005b6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sql_server/pyodbc/compiler.py
Expand Up @@ -278,7 +278,7 @@ def as_sql(self):
sql, params = super(SQLInsertCompiler, self).as_sql()
meta = self.query.get_meta()
quoted_table = self.connection.ops.quote_name(meta.db_table)
if meta.pk.attname in self.query.columns and meta.pk.__class__.__name__ == "AutoField":
if meta.pk.db_column in self.query.columns and meta.pk.__class__.__name__ == "AutoField":
if len(self.query.columns) == 1 and not params:
sql = "INSERT INTO %s DEFAULT VALUES" % quoted_table
else:
Expand Down
2 changes: 1 addition & 1 deletion sql_server/pyodbc/query.py
Expand Up @@ -73,7 +73,7 @@ def _insert_as_sql(self, *args, **kwargs):
quoted_table = self.connection.ops.quote_name(meta.db_table)
# Get (sql, params) from original InsertQuery.as_sql
sql, params = self._orig_as_sql(*args, **kwargs)
if meta.pk.attname in self.columns and meta.pk.__class__.__name__ == "AutoField":
if meta.pk.db_column in self.columns and meta.pk.__class__.__name__ == "AutoField":
if len(self.columns) == 1 and not params:
sql = "INSERT INTO %s DEFAULT VALUES" % quoted_table
else:
Expand Down

0 comments on commit 65005b6

Please sign in to comment.