From 50e6073539a721fc57d0bfaf43dc7f4b3706b501 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Tue, 16 Aug 2016 12:26:21 +0200 Subject: [PATCH] Fix mysql binary comparison MySQL doesn't do case sensitive filtering by default, so our DB API forces comparisons to be case sensitive when looking for hosts. Existing code was not being tested at the gate because our check to confirm a MySQL connection was too strict and the actual operator used for the comparison was wrong. This patch improves the connection type check to be more inclusive -now the code path it will be run at the gate- and it fixes the operator to use the right one. Change-Id: Ie2da2eabbab1eb64106f99845dc82a60de14f036 Closes-Bug: #1613624 --- cinder/db/sqlalchemy/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index 5a5af77882a..78e3f201530 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -396,9 +396,10 @@ def _filter_host(field, value, match_level=None): match_level = 'host' # Mysql is not doing case sensitive filtering, so we force it - if CONF.database.connection.startswith('mysql:'): + conn_str = CONF.database.connection + if conn_str.startswith('mysql') and conn_str[5] in ['+', ':']: cmp_value = func.binary(value) - like_op = 'LIKE_BINARY' + like_op = 'LIKE BINARY' else: cmp_value = value like_op = 'LIKE'