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
0a33817a
Commit
0a33817a
authored
3 years ago
by
Lelieveld,J.R.J. (Joris)
Browse files
Options
Downloads
Patches
Plain Diff
With statement hotfix
parent
860050d3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aql/convertQuery.go
+6
-6
6 additions, 6 deletions
aql/convertQuery.go
with
6 additions
and
6 deletions
aql/convertQuery.go
+
6
−
6
View file @
0a33817a
...
...
@@ -16,28 +16,28 @@ func (s *Service) ConvertQuery(JSONQuery *entity.IncomingQueryJSON) (*string, er
// Check to make sure all indexes exist
// The largest possible id for an entity
largestEntityI
d
:=
len
(
JSONQuery
.
Entities
)
-
1
largestEntityI
D
:=
len
(
JSONQuery
.
Entities
)
-
1
// The largest possible id for a relation
largestRelationI
d
:=
len
(
JSONQuery
.
Relations
)
-
1
largestRelationI
D
:=
len
(
JSONQuery
.
Relations
)
-
1
// Make sure no entity should be returned that is outside the range of that list
for
_
,
e
:=
range
JSONQuery
.
Return
.
Entities
{
// If this entity references an entity that is outside the range
if
e
>
largestEntityI
d
||
e
<
0
{
if
e
>
largestEntityI
D
||
e
<
0
{
return
nil
,
errors
.
New
(
"non-existing entity referenced in return"
)
}
}
// Make sure that no relation mentions a non-existing entity
for
_
,
r
:=
range
JSONQuery
.
Relations
{
if
r
.
EntityFrom
>
largestEntityI
d
||
r
.
EntityTo
>
largestEntityI
d
{
if
r
.
EntityFrom
>
largestEntityI
D
||
r
.
EntityTo
>
largestEntityI
D
{
return
nil
,
errors
.
New
(
"non-exisiting entity referenced in relation"
)
}
}
// Make sure no non-existing relation is tried to be returned
for
_
,
r
:=
range
JSONQuery
.
Return
.
Relations
{
if
r
>
largestRelationI
d
||
r
<
0
{
if
r
>
largestRelationI
D
||
r
<
0
{
return
nil
,
errors
.
New
(
"non-existing relation referenced in return"
)
}
}
...
...
@@ -253,7 +253,7 @@ func createRelationLetWithFromEntity(relation *entity.QueryRelationStruct, name
// Add a WITH statement if the collection of entityTo is not yet included
if
(
*
entities
)[(
*
relation
)
.
EntityFrom
]
.
Type
!=
(
*
entities
)[(
*
relation
)
.
EntityTo
]
.
Type
{
header
=
fmt
.
Sprintf
(
"WITH %v
\n
%v"
,
(
*
entities
)[(
*
relation
)
.
EntityTo
]
.
Type
,
header
)
header
=
fmt
.
Sprintf
(
"
%v
\n\t
WITH %v
"
,
header
,
(
*
entities
)[(
*
relation
)
.
EntityTo
]
.
Type
)
}
}
...
...
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