[Django] #33451: queryset_object.query results does not add quotes around string values

7 views
Skip to first unread message

Django

unread,
Jan 19, 2022, 2:34:26 PM1/19/22
to django-...@googlegroups.com
#33451: queryset_object.query results does not add quotes around string values
-------------------------------------------+------------------------
Reporter: rajukumar-rjk | Owner: (none)
Type: Bug | Status: new
Component: Error reporting | Version: 4.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
// queryset
{{{
queryset = (FormDataValues.objects
.filter(testing_cycle='BL')
.values(location_name=F(location_name))
)

print(queryset.query)
}}}

// result would be

{{{
SELECT `school`.`school_name` AS `location_name` FROM `form_data_values`
WHERE ( `form_data`.`testing_cycle` = BL)
}}}

The result has a small issue, look at the value ("BL") that is being
filtered, It is string so there should have been single quotes around it.

Many of occasions, I just paste the generated SQL in the MySQL editor but
in order to run the whole SQL syntax I need to add quotes around the
string values. This becomes a big issues with the complex sql.

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

Django

unread,
Jan 19, 2022, 3:57:40 PM1/19/22
to django-...@googlegroups.com
#33451: queryset_object.query results does not add quotes around string values
-------------------------------------+-------------------------------------
Reporter: Raju Kumar Singh | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* owner: (none) => nobody
* resolution: => duplicate
* status: new => closed
* component: Error reporting => Database layer (models, ORM)


Comment:

Duplicate of #25705.

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

Reply all
Reply to author
Forward
0 new messages