Opened 2 years ago

Closed 2 years ago

#33987 closed Bug (invalid)

values() and db_column aliases do not play nicely together

Reported by: John Obelenus Owned by: nobody
Component: Database layer (models, ORM) Version: 3.2
Severity: Normal Keywords: values db_column queryset
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I've got a django model

class Foo
  _bar = models.CharField(db_column='bar', ...)
  ...

And in some custom queries

..., foo_queryset.values('_bar') ...

Whenever I reference the django field name definition I get a "can't adapt type" Error
Whenever I reference the database column name definition I get a "model does not have that field use _bar" Error

Trying to use annotate to "massage" the SQL does not get me out of this chicken and egg situation.

What should I be trying here?

Change History (1)

comment:1 by Mariusz Felisiak, 2 years ago

Resolution: invalid
Status: newclosed

Thanks for this report, however I cannot reproduce this issue with:

Author.objects.values('_bar')

and you should always use a field name, i.e. _bar. Please use one of support channels.

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