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
Laurent S
erp5
Commits
ae7c1a91
Commit
ae7c1a91
authored
Oct 31, 2014
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
full text: update testSQLCatalog.py for Mroonga.
parent
67964219
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
38 deletions
+56
-38
product/ZSQLCatalog/tests/testSQLCatalog.py
product/ZSQLCatalog/tests/testSQLCatalog.py
+56
-38
No files found.
product/ZSQLCatalog/tests/testSQLCatalog.py
View file @
ae7c1a91
...
@@ -168,8 +168,10 @@ class DummyCatalog(SQLCatalog):
...
@@ -168,8 +168,10 @@ class DummyCatalog(SQLCatalog):
sql_catalog_keyword_search_keys
=
(
'keyword'
,
)
sql_catalog_keyword_search_keys
=
(
'keyword'
,
)
sql_catalog_datetime_search_keys
=
(
'date'
,
)
sql_catalog_datetime_search_keys
=
(
'date'
,
)
sql_catalog_full_text_search_keys
=
(
'fulltext'
,
)
sql_catalog_full_text_search_keys
=
(
'
old_
fulltext'
,
)
sql_catalog_scriptable_keys
=
(
'scriptable_keyword | scriptableKeyScript'
,
)
sql_catalog_scriptable_keys
=
(
'scriptable_keyword | scriptableKeyScript'
,
)
sql_catalog_search_keys
=
(
'fulltext | MroongaFullTextKey'
,
'fulltext_boolean | MroongaBooleanFullTextKey'
,)
def
getColumnMap
(
self
):
def
getColumnMap
(
self
):
"""
"""
...
@@ -180,7 +182,9 @@ class DummyCatalog(SQLCatalog):
...
@@ -180,7 +182,9 @@ class DummyCatalog(SQLCatalog):
'default'
:
[
'foo'
,
],
'default'
:
[
'foo'
,
],
'keyword'
:
[
'foo'
,
],
'keyword'
:
[
'foo'
,
],
'date'
:
[
'foo'
,
],
'date'
:
[
'foo'
,
],
'old_fulltext'
:
[
'foo'
,
],
'fulltext'
:
[
'foo'
,
],
'fulltext'
:
[
'foo'
,
],
'fulltext_boolean'
:
[
'foo'
,
],
'other_uid'
:
[
'bar'
,
],
'other_uid'
:
[
'bar'
,
],
'ambiguous_mapping'
:
[
'foo'
,
'bar'
],
'ambiguous_mapping'
:
[
'foo'
,
'bar'
],
}
}
...
@@ -495,8 +499,8 @@ class TestSQLCatalog(ERP5TypeTestCase):
...
@@ -495,8 +499,8 @@ class TestSQLCatalog(ERP5TypeTestCase):
# This example introduces impossible-to-merge search text criterion, which
# This example introduces impossible-to-merge search text criterion, which
# is allowed as long as
# is allowed as long as
reference_query
=
ReferenceQuery
(
reference_query
=
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
atch
'
,
fulltext
=
'a'
),
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
roonga
'
,
fulltext
=
'a'
),
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
atch
'
,
fulltext
=
'b'
),
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
roonga
'
,
fulltext
=
'b'
),
operator
=
'not'
),
operator
=
'and'
),
operator
=
'and'
)
operator
=
'not'
),
operator
=
'and'
),
operator
=
'and'
)
self
.
catalog
(
reference_query
,
{
'fulltext'
:
'a NOT b'
})
self
.
catalog
(
reference_query
,
{
'fulltext'
:
'a NOT b'
})
# The same, with an order by, must raise
# The same, with an order by, must raise
...
@@ -504,15 +508,15 @@ class TestSQLCatalog(ERP5TypeTestCase):
...
@@ -504,15 +508,15 @@ class TestSQLCatalog(ERP5TypeTestCase):
{
'fulltext'
:
'a NOT b'
,
'order_by_list'
:
[(
'fulltext'
,
),
]},
{
'fulltext'
:
'a NOT b'
,
'order_by_list'
:
[(
'fulltext'
,
),
]},
check_search_text
=
False
)
check_search_text
=
False
)
# If one want to sort on, he must use the equivalent FullText syntax:
# If one want to sort on, he must use the equivalent FullText syntax:
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
atch_boolean
'
,
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
roonga
'
,
fulltext
=
MatchList
([
'a -b'
,
'-b a'
])),
operator
=
'and'
),
fulltext
=
MatchList
([
'a -b'
,
'-b a'
])),
operator
=
'and'
),
{
'fulltext'
:
'a -b'
,
'order_by_list'
:
[(
'fulltext'
,
),
]},
{
'fulltext'
:
'a -b'
,
'order_by_list'
:
[(
'fulltext'
,
),
]},
check_search_text
=
False
)
check_search_text
=
False
)
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
atch
'
,
fulltext
=
'a'
),
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
roonga
'
,
fulltext
=
'a'
),
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
atch
'
,
fulltext
=
'b'
),
operator
=
'not'
),
operator
=
'or'
),
operator
=
'and'
),
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
roonga
'
,
fulltext
=
'b'
),
operator
=
'not'
),
operator
=
'or'
),
operator
=
'and'
),
{
'fulltext'
:
'a OR NOT b'
})
{
'fulltext'
:
'a OR NOT b'
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
atch
'
,
fulltext
=
'a'
),
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
roonga
'
,
fulltext
=
'a'
),
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
atch
'
,
fulltext
=
'b'
),
operator
=
'not'
),
operator
=
'and'
),
operator
=
'and'
),
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
roonga
'
,
fulltext
=
'b'
),
operator
=
'not'
),
operator
=
'and'
),
operator
=
'and'
),
{
'fulltext'
:
'a AND NOT b'
})
{
'fulltext'
:
'a AND NOT b'
})
def
test_006_testRelatedKey_with_multiple_join
(
self
):
def
test_006_testRelatedKey_with_multiple_join
(
self
):
...
@@ -540,7 +544,7 @@ class TestSQLCatalog(ERP5TypeTestCase):
...
@@ -540,7 +544,7 @@ class TestSQLCatalog(ERP5TypeTestCase):
check_search_text
=
False
)
check_search_text
=
False
)
def
test_009_testFullTextKey
(
self
):
def
test_009_testFullTextKey
(
self
):
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
atch
'
,
fulltext
=
'a'
),
operator
=
'and'
),
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'm
roonga
'
,
fulltext
=
'a'
),
operator
=
'and'
),
{
'fulltext'
:
'a'
})
{
'fulltext'
:
'a'
})
def
test_isAdvancedSearchText
(
self
):
def
test_isAdvancedSearchText
(
self
):
...
@@ -551,15 +555,20 @@ class TestSQLCatalog(ERP5TypeTestCase):
...
@@ -551,15 +555,20 @@ class TestSQLCatalog(ERP5TypeTestCase):
def
test_FullTextSearchMergesQueries
(
self
):
def
test_FullTextSearchMergesQueries
(
self
):
"""
"""
XXX this test is for old FullTextKey, not for MroongaFullTextKey
that merges queries only when logical_operator is 'and'. Also
_renderValueAsSearchText it not perfect so that we cannot use the
test codes below for mroonga search key.
FullText criterion on the same scope must be merged into one query.
FullText criterion on the same scope must be merged into one query.
Logical operator is ignored, as fulltext operators are expected instead.
Logical operator is ignored, as fulltext operators are expected instead.
"""
"""
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
fulltext
=
'a b'
),
operator
=
'and'
),
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
old_
fulltext
=
'a b'
),
operator
=
'and'
),
{
'fulltext'
:
'a AND b'
})
{
'
old_
fulltext'
:
'a AND b'
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
fulltext
=
'a b'
),
operator
=
'and'
),
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
old_
fulltext
=
'a b'
),
operator
=
'and'
),
{
'fulltext'
:
'a OR b'
})
{
'
old_
fulltext'
:
'a OR b'
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
fulltext
=
'a b'
),
operator
=
'not'
),
operator
=
'and'
),
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
old_
fulltext
=
'a b'
),
operator
=
'not'
),
operator
=
'and'
),
{
'fulltext'
:
'NOT (a b)'
})
{
'
old_
fulltext'
:
'NOT (a b)'
})
def
test_NoneValueToSimpleQuery
(
self
):
def
test_NoneValueToSimpleQuery
(
self
):
"""
"""
...
@@ -583,60 +592,69 @@ class TestSQLCatalog(ERP5TypeTestCase):
...
@@ -583,60 +592,69 @@ class TestSQLCatalog(ERP5TypeTestCase):
def
test_FullTextBooleanMode
(
self
):
def
test_FullTextBooleanMode
(
self
):
"""
"""
XXX this test is for old FullTextKey, not for MroongaFullTextKey
that does no automatic mode switch.
Fulltext searches must switch automatically to boolean mode if boolean
Fulltext searches must switch automatically to boolean mode if boolean
operators are found in search value.
operators are found in search value.
"""
"""
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match_boolean'
,
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match_boolean'
,
fulltext
=
MatchList
([
'a*'
])),
operator
=
'and'
),
old_
fulltext
=
MatchList
([
'a*'
])),
operator
=
'and'
),
{
'fulltext'
:
'a*'
})
{
'
old_
fulltext'
:
'a*'
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match_boolean'
,
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match_boolean'
,
fulltext
=
MatchList
([
'a* b'
])),
operator
=
'and'
),
old_
fulltext
=
MatchList
([
'a* b'
])),
operator
=
'and'
),
{
'fulltext'
:
'a* b'
})
{
'
old_
fulltext'
:
'a* b'
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
fulltext
=
'*a'
),
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
old_
fulltext
=
'*a'
),
operator
=
'and'
),
operator
=
'and'
),
{
'fulltext'
:
'*a'
})
{
'
old_
fulltext'
:
'*a'
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
fulltext
=
'a'
),
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
old_
fulltext
=
'a'
),
operator
=
'and'
),
operator
=
'and'
),
{
'fulltext'
:
'a'
})
{
'
old_
fulltext'
:
'a'
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
fulltext
=
'a+b'
),
operator
=
'and'
),
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
old_
fulltext
=
'a+b'
),
operator
=
'and'
),
{
'fulltext'
:
'a+b'
})
{
'
old_
fulltext'
:
'a+b'
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match_boolean'
,
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match_boolean'
,
fulltext
=
MatchList
([
'a +b'
,
'+b a'
])),
operator
=
'and'
),
old_
fulltext
=
MatchList
([
'a +b'
,
'+b a'
])),
operator
=
'and'
),
{
'fulltext'
:
'a +b'
},
check_search_text
=
False
)
{
'
old_
fulltext'
:
'a +b'
},
check_search_text
=
False
)
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'='
,
uid
=
'foo'
),
ReferenceQuery
(
operator
=
'='
,
uid
=
'foo'
),
ReferenceQuery
(
operator
=
'match_boolean'
,
ReferenceQuery
(
operator
=
'match_boolean'
,
fulltext
=
MatchList
([
'+a b'
,
'b +a'
])),
old_
fulltext
=
MatchList
([
'+a b'
,
'b +a'
])),
operator
=
'and'
),
operator
=
'and'
),
{
'fulltext'
:
'+a b uid:foo'
})
operator
=
'and'
),
operator
=
'and'
),
{
'
old_
fulltext'
:
'+a b uid:foo'
})
def
test_FullTextQuoting
(
self
):
def
test_FullTextQuoting
(
self
):
"""
XXX this test is for old FullTextKey, not for MroongaFullTextKey
that merges queries only when logical_operator is 'and'. Also
_renderValueAsSearchText it not perfect so that we cannot use the
test codes below for mroonga search key.
"""
# Quotes must be kept
# Quotes must be kept
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
fulltext
=
'"a"'
),
operator
=
'and'
),
old_
fulltext
=
'"a"'
),
operator
=
'and'
),
{
'fulltext'
:
'"a"'
})
{
'
old_
fulltext'
:
'"a"'
})
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
fulltext
=
'"foo" bar "baz"'
),
operator
=
'and'
),
old_
fulltext
=
'"foo" bar "baz"'
),
operator
=
'and'
),
{
'fulltext'
:
'"foo" bar "baz"'
})
{
'
old_
fulltext'
:
'"foo" bar "baz"'
})
# ...But each column must follow rules defined in configured SearchKey for
# ...But each column must follow rules defined in configured SearchKey for
# that column (in this case: quotes must be stripped).
# that column (in this case: quotes must be stripped).
ref_query
=
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
ref_query
=
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
fulltext
=
'"foo" bar'
),
ReferenceQuery
(
operator
=
'='
,
old_
fulltext
=
'"foo" bar'
),
ReferenceQuery
(
operator
=
'='
,
default
=
'hoge
\
"
pon'
),
operator
=
'and'
),
operator
=
'and'
)
default
=
'hoge
\
"
pon'
),
operator
=
'and'
),
operator
=
'and'
)
self
.
catalog
(
ref_query
,
{
self
.
catalog
(
ref_query
,
{
'keyword'
:
'default:"hoge
\
\
"pon" AND
fulltext:("foo"
bar)'
})
'keyword'
:
'default:"hoge
\
\
"pon" AND
old_fulltext:("foo" AND
bar)'
})
self
.
catalog
(
ref_query
,
{
self
.
catalog
(
ref_query
,
{
'fulltext'
:
'"foo" bar AND default:"hoge
\
\
"pon"'
})
'
old_
fulltext'
:
'"foo" bar AND default:"hoge
\
\
"pon"'
})
ref_query
=
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
ref_query
=
ReferenceQuery
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'match'
,
fulltext
=
'"
\
\
"foo
\
\
" bar"'
),
ReferenceQuery
(
operator
=
'='
,
old_
fulltext
=
'"
\
\
"foo
\
\
" bar"'
),
ReferenceQuery
(
operator
=
'='
,
default
=
'hoge
\
"
pon'
),
operator
=
'and'
),
operator
=
'and'
)
default
=
'hoge
\
"
pon'
),
operator
=
'and'
),
operator
=
'and'
)
self
.
catalog
(
ref_query
,
{
self
.
catalog
(
ref_query
,
{
'keyword'
:
'default:"hoge
\
\
"pon" AND fulltext:"
\
\
"foo
\
\
" bar"'
})
'keyword'
:
'default:"hoge
\
\
"pon" AND
old_
fulltext:"
\
\
"foo
\
\
" bar"'
})
def
test_DefaultKeyTextRendering
(
self
):
def
test_DefaultKeyTextRendering
(
self
):
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'like'
,
default
=
'a% b'
),
operator
=
'and'
),
self
.
catalog
(
ReferenceQuery
(
ReferenceQuery
(
operator
=
'like'
,
default
=
'a% b'
),
operator
=
'and'
),
...
...
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