Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-conversion
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GraphPolaris
query-conversion
Commits
f7cb694c
Commit
f7cb694c
authored
1 year ago
by
Leonardo Christino
Browse files
Options
Downloads
Patches
Plain Diff
add extra test for like logic
parent
9c6d7d80
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#126745
failed
1 year ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cypherv2/convertQuery_test.go
+67
-12
67 additions, 12 deletions
cypherv2/convertQuery_test.go
with
67 additions
and
12 deletions
cypherv2/convertQuery_test.go
+
67
−
12
View file @
f7cb694c
...
...
@@ -81,8 +81,8 @@ func TestV2NoLogic(t *testing.T) {
}
t
.
Log
(
*
cypher
)
answer
:=
`MATCH path1 = ((p1:Person)<-[:DIRECTED*1..1]-(m1:Movie))
MATCH path2 = ((p1:Person)<-[:IN_GENRE*1..1]-(g1:Genre))
answer
:=
`MATCH path1 = ((p1:Person)<-[:DIRECTED*1..1]-(m1:Movie))
MATCH path2 = ((p1:Person)<-[:IN_GENRE*1..1]-(g1:Genre))
RETURN * LIMIT 5000`
fmt
.
Printf
(
"Cypher: %s
\n
"
,
answer
)
...
...
@@ -150,7 +150,7 @@ func TestV2Simple(t *testing.T) {
}
t
.
Log
(
*
cypher
)
answer
:=
`MATCH path1 = ((p1:Person)<-[:DIRECTED*1..1]-(m1:Movie))
answer
:=
`MATCH path1 = ((p1:Person)<-[:DIRECTED*1..1]-(m1:Movie))
MATCH path2 = ((p1:Person)<-[:IN_GENRE*1..1]-(g1:Genre))
WHERE (p1.name <> "Raymond Campbell")
RETURN * LIMIT 5000`
...
...
@@ -211,7 +211,7 @@ func TestV2GroupBy(t *testing.T) {
}
t
.
Log
(
*
cypher
)
answer
:=
`MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
answer
:=
`MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
MATCH path2 = ((p2:Person))
WHERE ((movie.imdbRating < 7.500000) AND (p2.age = p1.age))
RETURN path2 LIMIT 5000`
...
...
@@ -264,8 +264,8 @@ func TestV2NoLabel(t *testing.T) {
}
t
.
Log
(
*
cypher
)
answer
:=
`MATCH path1 = ((p1)<-[acted*1..1]-(movie:Movie))
WHERE ((movie.year - p1.year) < 10.000000)
answer
:=
`MATCH path1 = ((p1)<-[acted*1..1]-(movie:Movie))
WHERE ((movie.year - p1.year) < 10.000000)
RETURN * LIMIT 5000`
fmt
.
Printf
(
"Cypher: %s
\n
"
,
answer
)
...
...
@@ -322,7 +322,7 @@ func TestV2NoDepth(t *testing.T) {
t
.
Log
(
*
cypher
)
answer
:=
`MATCH path1 = ((p1)<-[acted]-(movie:Movie))
answer
:=
`MATCH path1 = ((p1)<-[acted]-(movie:Movie))
MATCH path2 = ((p2))
WHERE ((movie.imdbRating < 7.500000) AND (p2.age = p1.age))
RETURN * LIMIT 5000`
...
...
@@ -377,7 +377,7 @@ func TestV2WithAverage(t *testing.T) {
t
.
Log
(
*
cypher
)
answer
:=
`MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
WITH avg(p1.age) AS p1_age_avg
WITH avg(p1.age) AS p1_age_avg
MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
WHERE (p1.age < p1_age_avg)
RETURN * LIMIT 5000`
...
...
@@ -449,7 +449,7 @@ func TestV2WithAverage2Paths(t *testing.T) {
answer
:=
`MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
MATCH path2 = ((p2:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
WITH avg(p1.age) AS p1_age_avg
WITH avg(p1.age) AS p1_age_avg
MATCH path1 = ((p1:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
MATCH path2 = ((p2:Person)<-[acted:ACTED_IN*1..1]-(movie:Movie))
WHERE (p1.age < p1_age_avg)
...
...
@@ -494,9 +494,9 @@ func TestV2SingleEntityWithLowerLike(t *testing.T) {
}
t
.
Log
(
*
cypher
)
answer
:=
`MATCH path1 = ((p1:Person))
MATCH path1 = ((p1:Person))
WHERE (toLower(p1.name) =~ (".*" + "john" + ".*"))
answer
:=
`MATCH path1 = ((p1:Person))
MATCH path1 = ((p1:Person))
WHERE (toLower(p1.name) =~ (".*" + "john" + ".*"))
RETURN * LIMIT 5000`
fmt
.
Printf
(
"Cypher: %s
\n
"
,
answer
)
...
...
@@ -506,6 +506,61 @@ func TestV2SingleEntityWithLowerLike(t *testing.T) {
assert
.
Equal
(
t
,
trimmedAnswer
,
trimmedCypher
)
}
func
TestV2Like
(
t
*
testing
.
T
)
{
query
:=
[]
byte
(
`{
"databaseName": "neo4j",
"query": [
{
"ID": "path_0",
"node": {
"ID": "id_1691576718400",
"label": "Employee",
"relation": {
"ID": "id_1691576720177",
"label": "REPORTS_TO",
"direction": "TO",
"node": {}
}
}
}
],
"limit": 500,
"return": [
"*"
],
"logic": [
"Like",
"@id_1691576718400.title",
"\"ale\""
]
}`
)
var
JSONQuery
entityv2
.
IncomingQueryJSON
err
:=
json
.
Unmarshal
(
query
,
&
JSONQuery
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
t
.
Log
(
err
)
}
s
:=
NewService
()
cypher
,
_
,
err
:=
s
.
ConvertQuery
(
&
JSONQuery
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
t
.
Log
(
err
)
}
t
.
Log
(
*
cypher
)
answer
:=
`MATCH path_0 = ((id_1691576718400:Employee)<-[id_1691576720177:REPORTS_TO]-())
WHERE (id_1691576718400.title =~ (".*" + "ale" + ".*"))
RETURN * LIMIT 500`
fmt
.
Printf
(
"Cypher: %s
\n
"
,
answer
)
trimmedCypher
:=
fixCypherSpaces
(
cypher
)
trimmedAnswer
:=
fixCypherSpaces
(
&
answer
)
assert
.
Equal
(
t
,
trimmedAnswer
,
trimmedCypher
)
}
// func TestSmallChain(t *testing.T) {
// query := []byte(`{
// "databaseName": "TweedeKamer",
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment