Opened 7 years ago

Closed 7 years ago

#6574 closed (wontfix)

Make queries not select fields that has db_type None

Reported by: oyvind Owned by: nobody
Component: Uncategorized Version: queryset-refactor
Severity: Keywords: db_type query fields
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Since sql_model_create in django/core/management/sql.py does not create fields that has db_type None, queries should not try to select a non-existing field.

Would be solvable in qs-rf by this small change in

http://code.djangoproject.com/browser/django/branches/queryset-refactor/django/db/models/sql/query.py#L392

elif self.default_cols:
    table_alias = self.tables[0]
    result = ['%s.%s' % (qn(table_alias), qn(f.column))
        for f in self.model._meta.fields]
    aliases = result[:]

Should be:

elif self.default_cols:
    table_alias = self.tables[0]
    result = ['%s.%s' % (qn(table_alias), qn(f.column))
        for f in self.model._meta.fields if f.db_type()]
    aliases = result[:]

Attachments (1)

db_type_none.diff (1.6 KB) - added by oyvind 7 years ago.
Added patch with tests for queryset-refactor

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by oyvind

Added patch with tests for queryset-refactor

comment:1 Changed 7 years ago by anonymous

  • Has patch set
  • Needs documentation set
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from SVN to queryset-refactor

comment:2 Changed 7 years ago by mtredinnick

  • Resolution set to wontfix
  • Status changed from new to closed

No, this doesn't look right. Those fields can be created via a different mechanism (as they are in GeoDjango, for exmaple).

What is the problem you're actually trying to solve here. Note that intelligent column selection is still work in progress on queryset-refactor -- I haven't merged in some of Justin's suggested changes, for example -- so don't get too far ahead of the ballgame here, but a description of what you're trying to do might help guide future design work.

Perhaps open another ticket with a description of what currently doesn't work so that it doesn't get confused with this one.

Note: See TracTickets for help on using tickets.
Back to Top