Modify the SQL's string from double quote to single quote.

Using double quotes for strings does not conform to the ANSI standard.
While MySQL accepts it, PostgreSQL raises an error.

This patch fixes crash when used with PostgreSQL.

Closes-Bug: #1606534
Change-Id: Id979043b1573bf2ea473e772c7ea7417c733d753
This commit is contained in:
Teng Fei 2016-07-27 19:31:15 +08:00 committed by Dmitry Tantsur
parent 823f6d26a2
commit 6ba331aad2
2 changed files with 5 additions and 1 deletions

View File

@ -497,7 +497,7 @@ def find_node(**attributes):
% (name, value))
value_list = []
for v in value:
value_list.append('name="%s" AND value="%s"' % (name, v))
value_list.append("name='%s' AND value='%s'" % (name, v))
stmt = ('select distinct uuid from attributes where ' +
' OR '.join(value_list))
rows = (db.model_query(db.Attribute.uuid).from_statement(

View File

@ -0,0 +1,4 @@
---
fixes:
- Use only single quotes for strings inside SQL statements. Fixes a crash
when PostgreSQL is used as a database backend.