-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'InsertQuery' object has no attribute 'columns' #30
Comments
Hi, i have the same problem. Could you resolve this issue? Best Regards, |
I did finally resolve it, but after a year or so I'm having trouble remembering. Over the last few years I've actually made a few little patches to pyodbc that made it work better with django. Looking through git logs I think I made a simple patch to the pyodbc/compiler.py file. In the file there's a function "as_sql", and in there I swapped out:
with:
... let me know if that doesn't work and i'll dig into it a bit more |
Thanks eviltandem for your support!! mmmm but this code is just under where i get the error code.. result.append('INSERT INTO %s' % qn(opts.db_table)) if self.return_id and self.connection.features.can_return_id_from_insert: Can you give me the columns part? Or maybe all the compile.py BR, |
Done!, I was replace all the as_sql code to the as_code from Github lastest version. It Works!! Thanks a lot eviltandem!! Best Regards, |
I am having a problem getting this project to run in various setups. These are all Linux and/or osX using FreeTDS.
I have an old version of one of these projects that a few years ago I customized to get working in these environments. I have lots of schema's in a pre-existing MsSQL box that I mapped to django ORM objects. The default database is postgres, but I have a particular app and all the models in it mapped with the multi-database support.
I'm running Django 1.5.5, pyodbc 3.0.6, and now django-pyodbc 0.10. I can run select style queries just fine like:
print Example.objects.all().count()
... anything that generates a select-style query seems ok. But anything like:
s = Example()
s.save()
results in:
Traceback (most recent call last):
File "/Users/ryan/Google Drive/code/cortex/temp.py", line 107, in
rss.save()
File "/Users/ryan/Google Drive/code/cortex/axons/models.py", line 62, in save
super(DateModel, self).save(_args, *_kwargs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 546, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 650, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/usr/local/lib/python2.7/site-packages/django/db/models/manager.py", line 215, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 1675, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 942, in execute_sql
for sql, params in self.as_sql():
File "/usr/local/lib/python2.7/site-packages/django_pyodbc/compiler.py", line 283, in as_sql
result.append('(%s)' % ', '.join([qn(c) for c in self.query.columns]))
AttributeError: 'InsertQuery' object has no attribute 'columns'
The text was updated successfully, but these errors were encountered: