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

syncdb/query sample generating error #129

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. python manage.py syncdb
2. from myapp.models import tablea
   tablea.objects.all() OR
   tablea.objects.filter(id=32)

What is the expected output? What do you see instead?
In all these cases the expected output is related to the structure of the DB.
syncdb should generate the models for the 70+ tables.
the queries should return the values I require.

Instead I get the following when trying to query- 

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 71, in __repr__
    data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 96, in __iter__
    self._fetch_all()
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 854, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 220, in iterator
    for row in compiler.results_iter():
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 710, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 771, in execute_sql
    sql, params = self.as_sql()
  File "/usr/local/lib/python2.6/dist-packages/sql_server/pyodbc/compiler.py", line 48, in as_sql
    self._get_ordering(out_cols, supports_offset_clause or not do_offset)
  File "/usr/local/lib/python2.6/dist-packages/sql_server/pyodbc/compiler.py", line 154, in _get_ordering
    ordering, ordering_group_by = self.get_ordering()
ValueError: too many values to unpack

And the following when attempting to do a syncdb - 

Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/commands/syncdb.py", line 112, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/sql.py", line 216, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/usr/local/lib/python2.6/dist-packages/django/dispatch/dispatcher.py", line 185, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/management/__init__.py", line 82, in create_permissions
    ctype = ContentType.objects.db_manager(db).get_for_model(klass)
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/contenttypes/models.py", line 47, in get_for_model
    defaults = {'name': smart_text(opts.verbose_name_raw)},
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/manager.py", line 154, in get_or_create
    return self.get_queryset().get_or_create(**kwargs)
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 373, in get_or_create
    return self.get(**lookup), False
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 301, in get
    num = len(clone)
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 77, in __len__
    self._fetch_all()
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 854, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 220, in iterator
    for row in compiler.results_iter():
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 710, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 771, in execute_sql
    sql, params = self.as_sql()
  File "/usr/local/lib/python2.6/dist-packages/sql_server/pyodbc/compiler.py", line 48, in as_sql
    self._get_ordering(out_cols, supports_offset_clause or not do_offset)
  File "/usr/local/lib/python2.6/dist-packages/sql_server/pyodbc/compiler.py", line 154, in _get_ordering
    ordering, ordering_group_by = self.get_ordering()
ValueError: too many values to unpack

What version of the product are you using? On what operating system?
debian v 6.0.1
django-pyodbc
django-pyodbc-azure
Microsoft SQL Server 2008 R2

Please provide any additional information below.

I can do isql/tsql fine.  nothing seems to be wrong with the setup of my 
odbc/freetds connections.  I can run queries fine from there.

I can also successfully do a query from pyodbc directly from python.

any other info you need let me know this is new to me :)

Original issue reported on code.google.com by whoisea...@gmail.com on 11 Nov 2013 at 4:32