Code

Opened 6 years ago

Closed 6 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 6 years ago.
Added patch with tests for queryset-refactor

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by oyvind

Added patch with tests for queryset-refactor

comment:1 Changed 6 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 6 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.