From 1eaf4a8f9dcfb06af4f5baa57b296a65a10f5601 Mon Sep 17 00:00:00 2001 From: YUKI Kaoru Date: Tue, 31 Dec 2019 06:52:50 +0900 Subject: [PATCH] add not expression --- csrestructuredquery/query.py | 4 ++++ tests/test_query.py | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/csrestructuredquery/query.py b/csrestructuredquery/query.py index 2837ae8..3f91155 100644 --- a/csrestructuredquery/query.py +++ b/csrestructuredquery/query.py @@ -59,3 +59,7 @@ class And(LogicalExpression): class Or(LogicalExpression): name = "or" + + +class Not(LogicalExpression): + name = "not" diff --git a/tests/test_query.py b/tests/test_query.py index d2336a6..1b970d4 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -1,6 +1,6 @@ from datetime import datetime -from csrestructuredquery.query import Query, And, Or +from csrestructuredquery.query import Query, And, Or, Not def test_文字列型と日時型は引用符で括られる(): @@ -16,3 +16,8 @@ def test_AND論理演算子(): def test_OR論理演算子(): expr = Or(("foo", "hoge"), ("bar", 123)) assert expr.query() == "(or foo:'hoge' bar:123)" + + +def test_NOT論理演算子(): + expr = Not(("foo", "hoge"), ("bar", 123)) + assert expr.query() == "(not foo:'hoge' bar:123)"