Opened 9 months ago

Closed 9 months ago

#23053 closed Uncategorized (invalid)

AS inversed in raw_sql doc section at: https://docs.djangoproject.com/en/1.7/topics/db/sql/

Reported by: lemarsupu@… Owned by: nobody
Component: Documentation Version: 1.7-rc-1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Person.objects.raw(SELECT first AS first_name,

... last AS last_name,
... bd AS birth_date,
... pk AS id,
... FROM some_other_table)

IT SHOULD BE:

Person.objects.raw(SELECT first_name AS first,

... last_name AS last,
... birh_date AS bd,
... id AS pk,
... FROM some_other_table)

AND:

name_map = {'first': 'first_name', 'last': 'last_name', 'bd': 'birth_date', 'pk': 'id'}
Person.objects.raw('SELECT * FROM some_other_table', translations=name_map)

IT SHOULD BE:

name_map = {'first_name': 'first', 'last_name': 'last', 'birth_date': 'bd', 'id': 'pk'}
Person.objects.raw('SELECT * FROM some_other_table', translations=name_map)

Change History (1)

comment:1 Changed 9 months ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

I don't think so. The model field names read first_name, last_name, so the raw query has to alias field names to match those.

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