[Django] #33987: values() and db_column aliases do not play nicely together

4 views
Skip to first unread message

Django

unread,
Sep 6, 2022, 5:30:43 PM9/6/22
to django-...@googlegroups.com
#33987: values() and db_column aliases do not play nicely together
-------------------------------------+-------------------------------------
Reporter: jobelenus | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 3.2
layer (models, ORM) | Keywords: values db_column
Severity: Normal | queryset
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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?

--
Ticket URL: <https://code.djangoproject.com/ticket/33987>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 7, 2022, 2:15:08 AM9/7/22
to django-...@googlegroups.com
#33987: values() and db_column aliases do not play nicely together
-------------------------------------+-------------------------------------
Reporter: John Obelenus | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: values db_column | Triage Stage:
queryset | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

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
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
support channels].

--
Ticket URL: <https://code.djangoproject.com/ticket/33987#comment:1>

Reply all
Reply to author
Forward
0 new messages