Fix get_action_plan_list filter error
When using 'query.filter_by(deleted_at=None)' Will generate the incorrect SQL 'audits.deleted_at', as below: SELECT * FROM action_plans INNER JOIN audits ON audits.id = action_plans.audit_id WHERE audits.uuid = '' AND audits.deleted_at IS NULL ORDER BY action_plans.id ASC The correct filter field is 'action_plans.deleted_at' Change-Id: Ie05f35233f78e82bc7af2c26c9effd62ea5f86ab Closes-Bug: #1698720
This commit is contained in:
@@ -815,7 +815,7 @@ class Connection(api.BaseConnection):
|
||||
query = self._set_eager_options(models.ActionPlan, query)
|
||||
query = self._add_action_plans_filters(query, filters)
|
||||
if not context.show_deleted:
|
||||
query = query.filter_by(deleted_at=None)
|
||||
query = query.filter(models.ActionPlan.deleted_at.is_(None))
|
||||
|
||||
return _paginate_query(models.ActionPlan, limit, marker,
|
||||
sort_key, sort_dir, query)
|
||||
|
||||
@@ -307,6 +307,14 @@ class DbActionPlanTestCase(base.DbTestCase):
|
||||
for r in res:
|
||||
self.assertEqual(audit['id'], r.audit_id)
|
||||
|
||||
self.dbapi.soft_delete_action_plan(action_plan1['uuid'])
|
||||
res = self.dbapi.get_action_plan_list(
|
||||
self.context,
|
||||
filters={'audit_uuid': audit['uuid']})
|
||||
|
||||
self.assertEqual([action_plan2['id']], [r.id for r in res])
|
||||
self.assertNotEqual([action_plan1['id']], [r.id for r in res])
|
||||
|
||||
def test_get_action_plan_list_with_filter_by_uuid(self):
|
||||
action_plan = self._create_test_action_plan()
|
||||
res = self.dbapi.get_action_plan_list(
|
||||
|
||||
Reference in New Issue
Block a user