diff options
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 2 | ||||
| -rw-r--r-- | nova/tests/test_db_api.py | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 9e987055c..1f5b07643 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1521,7 +1521,7 @@ def instance_get_all_by_filters(context, filters, sort_key, sort_dir): v = getattr(instance, filter_name) except AttributeError: return True - if v and filter_re.match(str(v)): + if v and filter_re.match(unicode(v)): return True return False diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 344ac9a74..045f63e73 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -1,4 +1,5 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 +# encoding=UTF8 # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. @@ -45,6 +46,14 @@ class DbApiTestCase(test.TestCase): result = db.instance_get_all_by_filters(self.context, {}) self.assertTrue(2, len(result)) + def test_instance_get_all_by_filters_unicode_value(self): + args = {'reservation_id': 'a', 'image_ref': 1, 'host': 'host1', + 'display_name': u'test♥'} + db.instance_create(self.context, args) + result = db.instance_get_all_by_filters(self.context.elevated(), + {'display_name': u'test'}) + self.assertEqual(1, len(result)) + def test_instance_get_all_by_filters_deleted(self): args1 = {'reservation_id': 'a', 'image_ref': 1, 'host': 'host1'} inst1 = db.instance_create(self.context, args1) |
