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
860050d3
Commit
860050d3
authored
3 years ago
by
Lelieveld,J.R.J. (Joris)
Browse files
Options
Downloads
Patches
Plain Diff
Added some comments
parent
06ff65cd
No related branches found
Branches containing commit
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
+7
-7
7 additions, 7 deletions
aql/convertQuery.go
with
7 additions
and
7 deletions
aql/convertQuery.go
+
7
−
7
View file @
860050d3
...
...
@@ -15,29 +15,29 @@ ConvertQuery converts an IncomingQueryJSON object into AQL
func
(
s
*
Service
)
ConvertQuery
(
JSONQuery
*
entity
.
IncomingQueryJSON
)
(
*
string
,
error
)
{
// Check to make sure all indexes exist
//
How many entities are there
num
Entit
ies
:=
len
(
JSONQuery
.
Entities
)
-
1
//
How many relations there
are
num
Relation
s
:=
len
(
JSONQuery
.
Relations
)
-
1
//
The largest possible id for an entity
largest
Entit
yId
:=
len
(
JSONQuery
.
Entities
)
-
1
//
The largest possible id for
a
re
lation
largest
Relation
Id
:=
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
>
num
Entit
ies
||
e
<
0
{
if
e
>
largest
Entit
yId
||
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
>
num
Entit
ies
||
r
.
EntityTo
>
num
Entit
ies
{
if
r
.
EntityFrom
>
largest
Entit
yId
||
r
.
EntityTo
>
largest
Entit
yId
{
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
>
num
Relation
s
||
r
<
0
{
if
r
>
largest
Relation
Id
||
r
<
0
{
return
nil
,
errors
.
New
(
"non-existing relation referenced in return"
)
}
}
...
...
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