Opened 2 years ago

Closed 2 years ago

#33451 closed Bug (duplicate)

queryset_object.query results does not add quotes around string values

Reported by: Raju Kumar Singh Owned by: nobody
Component: Database layer (models, ORM) Version: 4.0
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

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.

Change History (1)

comment:1 by Mariusz Felisiak, 2 years ago

Component: Error reportingDatabase layer (models, ORM)
Owner: set to nobody
Resolution: duplicate
Status: newclosed

Duplicate of #25705.

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