diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-08-01 19:37:35 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-08-01 19:37:35 +0000 |
| commit | db076de31eec46899fe2195d43a14beb9bb84073 (patch) | |
| tree | ff32d6bcc9a749429141755e988e7c8d1e68338e | |
| parent | acb0f81f8ae99c4d726abbfb059d5be6e23f3075 (diff) | |
| parent | ef579789065bd5eca90404e29463c63d538c5a01 (diff) | |
| download | nova-db076de31eec46899fe2195d43a14beb9bb84073.tar.gz nova-db076de31eec46899fe2195d43a14beb9bb84073.tar.xz nova-db076de31eec46899fe2195d43a14beb9bb84073.zip | |
Merge "Fix issue with filtering where a value is unicode."
| -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) |
