﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30791	str(Queryset.query) does not properly encapsulate values	Ryan Gartin		"**Expectation**: `print(str(qs.query))` will output correctly formatted SQL, ready to copy/paste, and execute.

**Bug**: Values such as dates, uuids are not encapsulated with single quotes. ArrayFields are incorrectly outputted. When debugging large queries, it is a pain to have to modify every output manually in order to successfully execute query outside of Django application.

**Environment**: Django 2.2.5, PostgreSQL 10.5, x86_64-apple-darwin14.5.0. Tested on PostgreSQL 9.6 as well.
**Note**: I was debugging earlier in the year on Django 2.0 and 2.1 and I feel that this was not an issue in those version.

**Example INCORRECT Output**:
`print(str(qs.query))`
SELECT  ....   FROM stuff
WHERE   ""asdf"".""end"" <= 2019-09-21 02:48:43.856895+00:00 
AND     ""asdf"".""start"" >= 2019-09-21 02:48:43.856895+00:00 
AND     ""asdf"".""uuid"" = 854af4a2-cb2a-4b22-ae04-90f14aa86ddd 
AND     ""asdf"".""date"" BETWEEN 1989-09-20 20:12:45.927138+00:00 AND 2001-09-20 18:03:09.927151+00:00 
AND     ""asdf"".""sex"" IN (f) 
AND     ""asdf"".""gender"" @> ['m']::VARCHAR(1)[] 


**FIX**:
Dates and uuid must be single quoted. 
CHARFIELD ""EQUAL"" query needs to be single quoted `= 'a'`
CHARFIELD ""IN"" query needs to be single quoted `IN ('a', 'b', 'c')`.
ARRAYFIELD (aka `character varying [] {1}` ) ""IN"" query should be in single quoted, encased in brackets, no quotes on individual characters  `@> '{a,b,c}' `
"	Bug	new	contrib.postgres	2.2	Normal		queryset, sql		Unreviewed	0	0	0	0	0	0
