#15586: Fields with missing columns populated when querying on PostgreSQL
-------------------------------------+-------------------------------------
               Reporter:  sebzur     |        Owner:  nobody
                 Status:  closed     |    Milestone:
              Component:  Database   |      Version:  1.2
  layer (models, ORM)                |     Keywords:  postgresql
             Resolution:  needsinfo  |    Has patch:  0
           Triage Stage:  Design     |  Needs tests:  0
  decision needed                    |
    Needs documentation:  0          |
Patch needs improvement:  0          |
-------------------------------------+-------------------------------------
Changes (by ramiro):

 * status:  reopened => closed
 * resolution:   => needsinfo


Comment:

 I can't reproduce this. Tried with Django trunk and 1.2.5

 * PostgresSQL version is 8.3.14
 * psycopg2 version is 2.0.7-4

 {{{
 #!python
 # t15586/models.py

 from django.db import models

 class MyModel(models.Model):
     name = models.CharField(max_length=255)
 }}}

 {{{
 $ ./manage.py dbshell
 Welcome to psql 8.3.14, the PostgreSQL interactive terminal.

 Type:  \copyright for distribution terms
        \h for help with SQL commands
        \? for help with psql commands
        \g or terminate with semicolon to execute query
        \q to quit

 dbname=> select * from t15586_mymodel;
  id
 ----
 (0 rows)

 dbname=>

 }}}

 {{{
 $ ./manage.py shell
 Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
 Type "copyright", "credits" or "license" for more information.

 IPython 0.8.4 -- An enhanced Interactive Python.
 ?         -> Introduction and overview of IPython's features.
 %quickref -> Quick reference.
 help      -> Python's own help system.
 object?   -> Details about 'object'. ?object also works, ?? prints more.

 In [1]: from django.db import connection

 In [2]: from t15586.models import MyModel

 In [3]: MyModel.objects.all()
 Out[3]:
 ---------------------------------------------------------------------------
 DatabaseError                             Traceback (most recent call
 last)

 dtest07/<ipython console> in <module>()

 /var/lib/python-support/python2.5/IPython/Prompts.pyc in __call__(self,
 arg)
     549
     550             # and now call a possibly user-defined print mechanism
 --> 551             manipulated_val = self.display(arg)
     552
     553             # user display hooks can change the variable to be
 stored in

 /var/lib/python-support/python2.5/IPython/Prompts.pyc in _display(self,
 arg)
     575             return IPython.generics.result_display(arg)
     576         except TryNext:
 --> 577             return self.shell.hooks.result_display(arg)
     578
     579     # Assign the default display method:

 /var/lib/python-support/python2.5/IPython/hooks.pyc in __call__(self,
 *args, **kw)
     133             #print "prio",prio,"cmd",cmd #dbg
     134             try:
 --> 135                 ret = cmd(*args, **kw)
     136                 return ret
     137             except ipapi.TryNext, exc:

 /var/lib/python-support/python2.5/IPython/hooks.pyc in
 result_display(self, arg)
     163
     164     if self.rc.pprint:
 --> 165         out = pformat(arg)
     166         if '\n' in out:
     167             # So that multi-line strings line up with the left
 column of

 /usr/lib/python2.5/pprint.pyc in pformat(self, object)
     109     def pformat(self, object):
     110         sio = _StringIO()
 --> 111         self._format(object, sio, 0, 0, {}, 0)
     112         return sio.getvalue()
     113

 /usr/lib/python2.5/pprint.pyc in _format(self, object, stream, indent,
 allowance, context, level)
     127             self._readable = False
     128             return
 --> 129         rep = self._repr(object, context, level - 1)
     130         typ = _type(object)
     131         sepLines = _len(rep) > (self._width - 1 - indent -
 allowance)

 /usr/lib/python2.5/pprint.pyc in _repr(self, object, context, level)
     193     def _repr(self, object, context, level):
     194         repr, readable, recursive = self.format(object,
 context.copy(),
 --> 195                                                 self._depth,
 level)
     196         if not readable:
     197             self._readable = False

 /usr/lib/python2.5/pprint.pyc in format(self, object, context, maxlevels,
 level)
     205         and whether the object represents a recursive construct.
     206         """
 --> 207         return _safe_repr(object, context, maxlevels, level)
     208
     209

 /usr/lib/python2.5/pprint.pyc in _safe_repr(object, context, maxlevels,
 level)
     290         return format % _commajoin(components), readable,
 recursive
     291
 --> 292     rep = repr(object)
     293     return rep, (rep and not rep.startswith('<')), False
     294

 django/db/models/query.py in __repr__(self)
      65
      66     def __repr__(self):
 ---> 67         data = list(self[:REPR_OUTPUT_SIZE + 1])
      68         if len(data) > REPR_OUTPUT_SIZE:
      69             data[-1] = "...(remaining elements truncated)..."

 django/db/models/query.py in __len__(self)
      80                 self._result_cache = list(self.iterator())
      81         elif self._iter:
 ---> 82             self._result_cache.extend(list(self._iter))
      83         return len(self._result_cache)
      84

 django/db/models/query.py in iterator(self)
     269         model = self.model
     270         compiler = self.query.get_compiler(using=db)
 --> 271         for row in compiler.results_iter():
     272             if fill_cache:
     273                 obj, _ = get_cached_row(model, row,

 django/db/models/sql/compiler.py in results_iter(self)
     675         fields = None
     676         has_aggregate_select = bool(self.query.aggregate_select)
 --> 677         for rows in self.execute_sql(MULTI):
     678             for row in rows:
     679                 if resolve_columns:

 django/db/models/sql/compiler.py in execute_sql(self, result_type)
     730
     731         cursor = self.connection.cursor()
 --> 732         cursor.execute(sql, params)
     733
     734         if not result_type:

 django/db/backends/util.py in execute(self, sql, params)
      13         start = time()
      14         try:
 ---> 15             return self.cursor.execute(sql, params)
      16         finally:
      17             stop = time()

 django/db/backends/postgresql_psycopg2/base.py in execute(self, query,
 args)
      42     def execute(self, query, args=None):
      43         try:
 ---> 44             return self.cursor.execute(query, args)
      45         except Database.IntegrityError, e:
      46             raise utils.IntegrityError,
 utils.IntegrityError(*tuple(e)), sys.exc_info()[2]

 DatabaseError: column t15586_mymodel.name does not exist
 LINE 1: SELECT "t15586_mymodel"."id", "t15586_mymodel"."name" FROM "...
                                       ^
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15586#comment:7>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to