From 56e40c5884e17f037ddbe7091d42fe6f8e602814 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 17 Nov 2005 15:00:23 +0000 Subject: [PATCH] Fixed #815 -- 'select' keyword in DB API calls is now quoted correctly. Thanks, Hugo git-svn-id: http://code.djangoproject.com/svn/django/trunk@1274 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/meta/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py index 328a2f449c..a8cd4112a1 100644 --- a/django/core/meta/__init__.py +++ b/django/core/meta/__init__.py @@ -1380,8 +1380,13 @@ def function_get_sql_clause(opts, **kwargs): _fill_table_cache(opts, select, tables, where, opts.db_table, [opts.db_table]) # Add any additional SELECTs passed in via kwargs. + def quote_only_if_word(word): + if word.find(' ')>=0: + return word + else: + return db.db.quote_name(word) if kwargs.get('select'): - select.extend(['(%s) AS %s' % (db.db.quote_name(s[1]), db.db.quote_name(s[0])) for s in kwargs['select']]) + select.extend(['(%s) AS %s' % (quote_only_if_word(s[1]), db.db.quote_name(s[0])) for s in kwargs['select']]) # ORDER BY clause order_by = []