From 3e2e2e557756a333c3b1579279b762298fbe63d2 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Tue, 27 Nov 2018 21:12:21 +0000 Subject: [PATCH] Sync up model_query module to neutron-lib The implementation of method 'apply_filters' in neutron_lib.db.model_query is updated [1]. This patch sync up the neutron's side implementation. [1] https://review.openstack.org/#/c/609847/ Change-Id: I180c0813bb433088f6037ff108327fd7a119512b --- neutron/db/_model_query.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/neutron/db/_model_query.py b/neutron/db/_model_query.py index a55acceab54..d1e6e5698d5 100644 --- a/neutron/db/_model_query.py +++ b/neutron/db/_model_query.py @@ -90,16 +90,8 @@ def apply_filters(query, model, filters, context=None): # do multiple equals matches query = query.filter( or_(*[column == v for v in value])) - elif isinstance(value, obj_utils.StringMatchingFilterObj): - if value.is_contains: - query = query.filter( - column.contains(value.contains)) - elif value.is_starts: - query = query.filter( - column.startswith(value.starts)) - elif value.is_ends: - query = query.filter( - column.endswith(value.ends)) + elif isinstance(value, obj_utils.FilterObj): + query = query.filter(value.filter(column)) elif None in value: # in_() operator does not support NULL element so we have # to do multiple equals matches