From 6ba331aad227ac9a08c746d624d78e25d0267177 Mon Sep 17 00:00:00 2001 From: Teng Fei Date: Wed, 27 Jul 2016 19:31:15 +0800 Subject: [PATCH] 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 --- ironic_inspector/node_cache.py | 2 +- .../notes/fix-crash-when-use-postgresql-ac6c708f48f55c83.yaml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-crash-when-use-postgresql-ac6c708f48f55c83.yaml diff --git a/ironic_inspector/node_cache.py b/ironic_inspector/node_cache.py index 2b1737597..02549c69f 100644 --- a/ironic_inspector/node_cache.py +++ b/ironic_inspector/node_cache.py @@ -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( diff --git a/releasenotes/notes/fix-crash-when-use-postgresql-ac6c708f48f55c83.yaml b/releasenotes/notes/fix-crash-when-use-postgresql-ac6c708f48f55c83.yaml new file mode 100644 index 000000000..4e6d968e4 --- /dev/null +++ b/releasenotes/notes/fix-crash-when-use-postgresql-ac6c708f48f55c83.yaml @@ -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.