Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
jio
Commits
23885d21
Commit
23885d21
authored
Dec 23, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
custom keys: changed folding example with cast_to and wildcard support
parent
c76af5ed
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
src/queries/core/simplequery.js
src/queries/core/simplequery.js
+1
-2
test/queries/keys.tests.js
test/queries/keys.tests.js
+9
-11
No files found.
src/queries/core/simplequery.js
View file @
23885d21
...
...
@@ -124,7 +124,6 @@ SimpleQuery.prototype.match = function (item, wildcard_character) {
checkKey
(
key
);
object_value
=
item
[
key
.
read_from
];
// default_match overrides the default '=' operator
default_match
=
key
.
default_match
;
// default_match can be a string
...
...
@@ -136,7 +135,7 @@ SimpleQuery.prototype.match = function (item, wildcard_character) {
// default_match overrides the default '=' operator
matchMethod
=
(
default_match
||
matchMethod
);
// but an explicit operator:
key
overrides default_match
// but an explicit operator:
parameter
overrides default_match
if
(
this
.
_spec
&&
this
.
_spec
.
operator
)
{
matchMethod
=
this
[
this
.
operator
];
}
...
...
test/queries/keys.tests.js
View file @
23885d21
...
...
@@ -437,7 +437,6 @@
// https://github.com/walling/unorm/
var
accentFold
=
function
(
s
)
{
var
map
=
[
[
new
RegExp
(
'
\\
s
'
,
'
gi
'
),
''
],
[
new
RegExp
(
'
[àáâãäå]
'
,
'
gi
'
),
'
a
'
],
[
new
RegExp
(
'
æ
'
,
'
gi
'
),
'
ae
'
],
[
new
RegExp
(
'
ç
'
,
'
gi
'
),
'
c
'
],
...
...
@@ -447,8 +446,7 @@
[
new
RegExp
(
'
[òóôõö]
'
,
'
gi
'
),
'
o
'
],
[
new
RegExp
(
'
œ
'
,
'
gi
'
),
'
oe
'
],
[
new
RegExp
(
'
[ùúûü]
'
,
'
gi
'
),
'
u
'
],
[
new
RegExp
(
'
[ýÿ]
'
,
'
gi
'
),
'
y
'
],
[
new
RegExp
(
'
\\
W
'
,
'
gi
'
),
''
]
[
new
RegExp
(
'
[ýÿ]
'
,
'
gi
'
),
'
y
'
]
];
map
.
forEach
(
function
(
o
)
{
...
...
@@ -466,24 +464,23 @@
test
(
'
Accent folding
'
,
function
()
{
equal
(
accentFold
(
'
àéîöùç
'
),
'
aeiouc
'
);
equal
(
accentFold
(
'
ÀÉÎÖÙÇ
'
),
'
AEIOUC
'
);
equal
(
accentFold
(
'
àéî öùç
'
),
'
aei ouc
'
);
});
test
(
'
Query with accent folding
(exact matching)
'
,
function
()
{
test
(
'
Query with accent folding
and wildcard
'
,
function
()
{
/*jslint unparam: true*/
var
doc_list
,
docList
=
function
()
{
return
[
{
'
identifier
'
:
'
àéîöùç
'
},
{
'
identifier
'
:
'
âèî ôùc
'
},
{
'
identifier
'
:
'
ÀÉÎÖÙÇ
'
},
{
'
identifier
'
:
'
b
'
}
];
},
keys
=
{
identifier
:
{
read_from
:
'
identifier
'
,
default_match
:
function
(
object_value
,
value
,
wildcard_character
)
{
// XXX todo: regexp & support wildcard_character
return
accentFold
(
object_value
)
===
accentFold
(
value
);
}
cast_to
:
accentFold
}
};
/*jslint unparam: false*/
...
...
@@ -492,11 +489,12 @@
complex_queries
.
QueryFactory
.
create
({
type
:
'
simple
'
,
key
:
keys
.
identifier
,
value
:
'
aei
ouc
'
value
:
'
aei
%
'
}).
exec
(
doc_list
);
deepEqual
(
doc_list
,
[
{
'
identifier
'
:
'
àéîöùç
'
}
],
'
It should be possible to query for an exact match regardless of accents
'
);
{
'
identifier
'
:
'
àéîöùç
'
},
{
'
identifier
'
:
'
âèî ôùc
'
}
],
'
It should be possible to query regardless of accents
'
);
});
...
...
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