From 4f7f9bd66d87cf5f69d1ea34bb16f171ba18a90b Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 29 May 2016 23:56:20 +0300 Subject: [PATCH] Minor refactoring --- m_librarian/search.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/m_librarian/search.py b/m_librarian/search.py index d431c30..2e761ed 100644 --- a/m_librarian/search.py +++ b/m_librarian/search.py @@ -19,19 +19,21 @@ def _mk_search_conditions_with_operator(table, case_sensitive, comparison_op, _expressions.append(table.q.id == value) if case_sensitive: for column, value in values.items(): - if column != 'id': - _expressions.append( - getattr(getattr(table.q, column), comparison_op)(value)) + if column == 'id': + continue + _expressions.append( + getattr(getattr(table.q, column), comparison_op)(value)) for expr, value in expressions: _expressions.append( getattr(expr, comparison_op)(value)) else: for column, value in values.items(): - if column != 'id': - _expressions.append( - getattr(func.lower( - getattr(table.q, column)), - comparison_op)(value.lower())) + if column == 'id': + continue + _expressions.append( + getattr(func.lower( + getattr(table.q, column)), + comparison_op)(value.lower())) for expr, value in expressions: _expressions.append( getattr(func.lower(expr), comparison_op)(value.lower())) -- 2.39.5