Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
6ffe8bde
Commit
6ffe8bde
authored
Nov 08, 2012
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle "is not null" inside SimpleQuery.
parent
25db71bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
product/ZSQLCatalog/Operator/ComparisonOperator.py
product/ZSQLCatalog/Operator/ComparisonOperator.py
+1
-0
product/ZSQLCatalog/Query/SimpleQuery.py
product/ZSQLCatalog/Query/SimpleQuery.py
+13
-4
product/ZSQLCatalog/tests/testSQLCatalog.py
product/ZSQLCatalog/tests/testSQLCatalog.py
+4
-0
No files found.
product/ZSQLCatalog/Operator/ComparisonOperator.py
View file @
6ffe8bde
...
...
@@ -183,5 +183,6 @@ operator_dict = {
'sphinxse'
:
SphinxSEComparisonOperator
(
'sphinxse'
),
'in'
:
MultivaluedComparisonOperator
(
'in'
),
'is'
:
MonovaluedComparisonOperator
(
'is'
),
'is not'
:
MonovaluedComparisonOperator
(
'is not'
,
'!='
),
}
product/ZSQLCatalog/Query/SimpleQuery.py
View file @
6ffe8bde
...
...
@@ -34,6 +34,13 @@ from zope.interface.verify import verifyClass
from
Products.ZSQLCatalog.SQLCatalog
import
profiler_decorator
,
list_type_list
from
zLOG
import
LOG
,
WARNING
NULL_SEARCH_TEXT_OPERATOR_DICT
=
{
'='
:
'is'
,
'!='
:
'is not'
,
}
for
value
in
NULL_SEARCH_TEXT_OPERATOR_DICT
.
values
():
NULL_SEARCH_TEXT_OPERATOR_DICT
[
value
]
=
value
class
SimpleQuery
(
Query
):
"""
A SimpleQuery represents a single comparison between a single column and
...
...
@@ -84,10 +91,12 @@ class SimpleQuery(Query):
else
:
comparison_operator
=
'in'
if
value
is
None
:
if
comparison_operator
==
'='
:
comparison_operator
=
'is'
elif
comparison_operator
!=
'is'
:
raise
ValueError
,
'None value with a non-"=" comparison_operator (%r). Not sure what to do.'
%
(
comparison_operator
,
)
try
:
comparison_operator
=
NULL_SEARCH_TEXT_OPERATOR_DICT
[
comparison_operator
]
except
KeyError
:
raise
ValueError
(
'Unexpected comparison_operator %r for None value.'
%
(
comparison_operator
,
))
elif
comparison_operator
==
'is'
:
raise
ValueError
,
'Non-None value (%r) with "is" comparison_operator. Not sure what to do.'
%
(
value
,
)
self
.
value
=
value
...
...
product/ZSQLCatalog/tests/testSQLCatalog.py
View file @
6ffe8bde
...
...
@@ -575,6 +575,10 @@ class TestSQLCatalog(ERP5TypeTestCase):
SimpleQuery
(
default
=
None
))
self
.
assertEqual
(
ReferenceQuery
(
operator
=
'is'
,
default
=
None
),
SimpleQuery
(
default
=
None
,
comparison_operator
=
'='
))
self
.
assertEqual
(
ReferenceQuery
(
operator
=
'is not'
,
default
=
None
),
SimpleQuery
(
default
=
None
,
comparison_operator
=
'!='
))
self
.
assertEqual
(
ReferenceQuery
(
operator
=
'is not'
,
default
=
None
),
SimpleQuery
(
default
=
None
,
comparison_operator
=
'is not'
))
self
.
assertRaises
(
ValueError
,
SimpleQuery
,
default
=
None
,
comparison_operator
=
'>='
)
self
.
assertRaises
(
ValueError
,
SimpleQuery
,
default
=
1
,
comparison_operator
=
'is'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment