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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
jio
Commits
8119f88b
Commit
8119f88b
authored
Jun 07, 2019
by
Tristan Cavelier
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
332807a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
5 deletions
+43
-5
dist/jio-latest.js
dist/jio-latest.js
+30
-3
test/queries/tests.js
test/queries/tests.js
+13
-2
No files found.
dist/jio-latest.js
View file @
8119f88b
...
...
@@ -6069,6 +6069,7 @@ var arrayExtend = function () {
return
newlist
;
},
mkSimpleQuery
=
function
(
key
,
value
,
operator
)
{
//TRISTAN var object = {"type": "simple", "key": key, "value": value.replace(/(?:\\(["\\])|(\\[^"\\]))/g, "$1$2")};
var
object
=
{
"
type
"
:
"
simple
"
,
"
key
"
:
key
,
"
value
"
:
value
};
if
(
operator
!==
undefined
)
{
object
.
operator
=
operator
;
...
...
@@ -6223,9 +6224,11 @@ case 15:
$$
[
$0
].
operator
=
$$
[
$0
-
1
]
;
this
.
$
=
$$
[
$0
];
break
;
case
17
:
console
.
log
(
17
,
$$
[
$0
]);
this
.
$
=
mkSimpleQuery
(
''
,
$$
[
$0
]);
break
;
case
18
:
console
.
log
(
18
,
$$
[
$0
-
1
]);
this
.
$
=
mkSimpleQuery
(
''
,
$$
[
$0
-
1
]);
break
;
}
...
...
@@ -7435,7 +7438,16 @@ return new Parser;
return
new
Query
(
key_schema
);
}
if
(
typeof
object
===
"
string
"
)
{
try
{
object
=
parseStringToObject
(
object
);
}
catch
(
error
)
{
if
(
error
.
hash
&&
error
.
hash
.
expected
&&
error
.
hash
.
expected
.
length
===
1
&&
error
.
hash
.
expected
[
0
]
===
"
'QUOTE'
"
)
{
return
new
query_class_dict
.
simple
({
value
:
object
});
}
throw
error
;
}
}
if
(
typeof
(
object
||
{}).
type
===
"
string
"
&&
query_class_dict
[
object
.
type
])
{
...
...
@@ -7445,6 +7457,20 @@ return new Parser;
"
Argument 1 is not a search text or a parsable object
"
);
};
function
ensureString
(
value
)
{
if
(
value
===
undefined
)
{
return
"
undefined
"
;
}
if
(
value
===
null
)
{
return
"
null
"
;
}
return
value
.
toString
();
}
function
renderSearchTextValue
(
value
)
{
value
=
ensureString
(
value
);
if
(
/
(?:
^
[
=!><
]
|
[\s
":
])
/
.
test
(
value
))
{
return
'
"
'
+
value
.
replace
(
/
((?:\\\\)
*
)\\
$/
,
"
$1
"
).
replace
(
/"/g
,
'
\\
"
'
)
+
'
"
'
;
}
return
value
;
}
function
objectToSearchText
(
query
)
{
var
i
=
0
,
query_list
=
null
,
...
...
@@ -7453,7 +7479,8 @@ return new Parser;
common_key
=
""
;
if
(
query
.
type
===
"
simple
"
)
{
return
(
query
.
key
?
query
.
key
+
"
:
"
:
""
)
+
(
query
.
operator
||
""
)
+
'
"
'
+
query
.
value
+
'
"
'
;
(
query
.
operator
||
""
)
+
'
'
+
renderSearchTextValue
(
query
.
value
);
}
if
(
query
.
type
===
"
complex
"
)
{
query_list
=
query
.
query_list
;
...
...
@@ -7484,7 +7511,7 @@ return new Parser;
for
(
i
=
0
;
i
<
query_list
.
length
;
i
+=
1
)
{
string_list
.
push
(
(
query_list
[
i
].
operator
||
""
)
+
'
"
'
+
query_list
[
i
].
value
+
'
"
'
'
'
+
renderSearchTextValue
(
query_list
[
i
].
value
)
);
}
}
else
{
...
...
test/queries/tests.js
View file @
8119f88b
...
...
@@ -396,14 +396,25 @@
);
deepEqual
(
jIO
.
Query
.
parseStringToObject
(
'
"
\
"a b
\
""
'
),
jIO
.
Query
.
parseStringToObject
(
'
"
\
\
"a b
\
\
""
'
),
{
"
type
"
:
"
simple
"
,
"
value
"
:
"
\"
a b
\"
"
,
"
key
"
:
""
,
"
value
"
:
'
"a b"
'
,
},
"
parseStringToObject('
\"\\\"
a b
\\\"\"
')
"
);
deepEqual
(
jIO
.
Query
.
parseStringToObject
(
'
a=b
'
),
{
"
type
"
:
"
simple
"
,
"
key
"
:
""
,
"
value
"
:
'
a=b
'
,
},
"
parseStringToObject('a=b')
"
);
deepEqual
(
jIO
.
QueryFactory
.
create
(
'
identifier: "
\\
"
'
).
toJSON
(),
{
...
...
Tristan Cavelier
@tc
·
Jun 07, 2019
Maintainer
See also
nexedi/erp5!877
See also https://lab.nexedi.com/nexedi/erp5/merge_requests/877
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