﻿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
1454	[patch] DB API quotes some SQL clauses that are not words and shouldn't be quoted	dja@…	Adrian Holovaty	"The DB API produces incorrect SQL code with get_list() and related functions if I pass it a ""select"" parameter that is not a word (identifier), but doesn't have spaces in it. It quotes the parameter when it shouldn't. For example:
{{{
  wordlist = words.get_list(select = { 'wordlen' : 'length(word)' })
}}}
This will produce, in part, ""{{{ SELECT [...] (""length(word)"") AS ""wordlen"" [...] }}}""

This patch is against v0.91. On the magic-removal branch, it looks like quote_only_if_word() in django/db/models/query.py has the same issue.

{{{
--- django/core/meta/__init__.py_0_91   2006-03-02 10:05:32.275065000 -0800
+++ django/core/meta/__init__.py        2006-03-02 10:07:04.622115000 -0800
@@ -1585,7 +1585,7 @@

 def function_get_sql_clause(opts, **kwargs):
     def quote_only_if_word(word):
-        if ' ' in word:
+        if re.search('\W', word):
             return word
         else:
             return db.db.quote_name(word)
}}}
"	defect	closed	Database layer (models, ORM)	0.91	normal	fixed	yut	tytyty	Unreviewed	1	0	0	0	0	0
