On 03/17/2014 04:04 PM, Joe Gordon wrote: > On Mon, Mar 17, 2014 at 2:16 PM, Chris Friesen > <chris.frie...@windriver.com <mailto:chris.frie...@windriver.com>> wrote:
> The original code looks like this: > > filters = {'uuid': filter_uuids, 'deleted_at': None} > instances = instance_obj.InstanceList.get___by_filters(context, > filters=filters) > > If I run that code, I get three instances, as expected. > > > If I change it to "filters = {'uuid': filter_uuids, 'deleted': 0}" > and rerun get_by_filters() then I get no instances in the result. > > > However, if I run "db.instance_get_all()" and look at the result, > there are three instances and the "deleted" field is zero in each case: > > (Pdb) db.instance_get_all(context)[__0]['deleted'] > 0 > (Pdb) db.instance_get_all(context)[__1]['deleted'] > 0 > (Pdb) db.instance_get_all(context)[__2]['deleted'] > 0 > > > So why does it fail if I try and filter by the "deleted" field? > > > > See > http://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py#n1848 Yes, I saw that and started tracing it. My filter is equivalent to 'deleted':False which ends up doing query_prefix = query_prefix.filter_by(deleted=0) query_prefix = query_prefix.\ filter(models.Instance.vm_state != vm_states.SOFT_DELETED) The first one behaves as expected and still shows three objects. (Pdb) query_prefix.filter_by(deleted=0).all() [<nova.db.sqlalchemy.models.Instance object at 0x6aa4390>, <nova.db.sqlalchemy.models.Instance object at 0x6aa0210>, <nova.db.sqlalchemy.models.Instance object at 0x6aa0dd0>] The second one filters out all of the objects and returns nothing. (Pdb) query_prefix.filter(models.Instance.vm_state != vm_states.SOFT_DELETED).all() [] Oddly, if I test for a vm_state of None it seems to work fine: (Pdb) query_prefix.filter(models.Instance.vm_state == None).all() [<nova.db.sqlalchemy.models.Instance object at 0x6ab8690>, <nova.db.sqlalchemy.models.Instance object at 0x6ab8590>, <nova.db.sqlalchemy.models.Instance object at 0x6b3ca90>] Any ideas? Chris _______________________________________________ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev