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 () {
...
@@ -6069,6 +6069,7 @@ var arrayExtend = function () {
return
newlist
;
return
newlist
;
},
mkSimpleQuery
=
function
(
key
,
value
,
operator
)
{
},
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
};
var
object
=
{
"
type
"
:
"
simple
"
,
"
key
"
:
key
,
"
value
"
:
value
};
if
(
operator
!==
undefined
)
{
if
(
operator
!==
undefined
)
{
object
.
operator
=
operator
;
object
.
operator
=
operator
;
...
@@ -6223,9 +6224,11 @@ case 15:
...
@@ -6223,9 +6224,11 @@ case 15:
$$
[
$0
].
operator
=
$$
[
$0
-
1
]
;
this
.
$
=
$$
[
$0
];
$$
[
$0
].
operator
=
$$
[
$0
-
1
]
;
this
.
$
=
$$
[
$0
];
break
;
break
;
case
17
:
case
17
:
console
.
log
(
17
,
$$
[
$0
]);
this
.
$
=
mkSimpleQuery
(
''
,
$$
[
$0
]);
this
.
$
=
mkSimpleQuery
(
''
,
$$
[
$0
]);
break
;
break
;
case
18
:
case
18
:
console
.
log
(
18
,
$$
[
$0
-
1
]);
this
.
$
=
mkSimpleQuery
(
''
,
$$
[
$0
-
1
]);
this
.
$
=
mkSimpleQuery
(
''
,
$$
[
$0
-
1
]);
break
;
break
;
}
}
...
@@ -7435,7 +7438,16 @@ return new Parser;
...
@@ -7435,7 +7438,16 @@ return new Parser;
return
new
Query
(
key_schema
);
return
new
Query
(
key_schema
);
}
}
if
(
typeof
object
===
"
string
"
)
{
if
(
typeof
object
===
"
string
"
)
{
try
{
object
=
parseStringToObject
(
object
);
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
"
&&
if
(
typeof
(
object
||
{}).
type
===
"
string
"
&&
query_class_dict
[
object
.
type
])
{
query_class_dict
[
object
.
type
])
{
...
@@ -7445,6 +7457,20 @@ return new Parser;
...
@@ -7445,6 +7457,20 @@ return new Parser;
"
Argument 1 is not a search text or a parsable object
"
);
"
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
)
{
function
objectToSearchText
(
query
)
{
var
i
=
0
,
var
i
=
0
,
query_list
=
null
,
query_list
=
null
,
...
@@ -7453,7 +7479,8 @@ return new Parser;
...
@@ -7453,7 +7479,8 @@ return new Parser;
common_key
=
""
;
common_key
=
""
;
if
(
query
.
type
===
"
simple
"
)
{
if
(
query
.
type
===
"
simple
"
)
{
return
(
query
.
key
?
query
.
key
+
"
:
"
:
""
)
+
return
(
query
.
key
?
query
.
key
+
"
:
"
:
""
)
+
(
query
.
operator
||
""
)
+
'
"
'
+
query
.
value
+
'
"
'
;
(
query
.
operator
||
""
)
+
'
'
+
renderSearchTextValue
(
query
.
value
);
}
}
if
(
query
.
type
===
"
complex
"
)
{
if
(
query
.
type
===
"
complex
"
)
{
query_list
=
query
.
query_list
;
query_list
=
query
.
query_list
;
...
@@ -7484,7 +7511,7 @@ return new Parser;
...
@@ -7484,7 +7511,7 @@ return new Parser;
for
(
i
=
0
;
i
<
query_list
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
query_list
.
length
;
i
+=
1
)
{
string_list
.
push
(
string_list
.
push
(
(
query_list
[
i
].
operator
||
""
)
+
(
query_list
[
i
].
operator
||
""
)
+
'
"
'
+
query_list
[
i
].
value
+
'
"
'
'
'
+
renderSearchTextValue
(
query_list
[
i
].
value
)
);
);
}
}
}
else
{
}
else
{
...
...
test/queries/tests.js
View file @
8119f88b
...
@@ -396,14 +396,25 @@
...
@@ -396,14 +396,25 @@
);
);
deepEqual
(
deepEqual
(
jIO
.
Query
.
parseStringToObject
(
'
"
\
"a b
\
""
'
),
jIO
.
Query
.
parseStringToObject
(
'
"
\
\
"a b
\
\
""
'
),
{
{
"
type
"
:
"
simple
"
,
"
type
"
:
"
simple
"
,
"
value
"
:
"
\"
a b
\"
"
,
"
key
"
:
""
,
"
value
"
:
'
"a b"
'
,
},
},
"
parseStringToObject('
\"\\\"
a b
\\\"\"
')
"
"
parseStringToObject('
\"\\\"
a b
\\\"\"
')
"
);
);
deepEqual
(
jIO
.
Query
.
parseStringToObject
(
'
a=b
'
),
{
"
type
"
:
"
simple
"
,
"
key
"
:
""
,
"
value
"
:
'
a=b
'
,
},
"
parseStringToObject('a=b')
"
);
deepEqual
(
deepEqual
(
jIO
.
QueryFactory
.
create
(
'
identifier: "
\\
"
'
).
toJSON
(),
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