From 860050d3998c9a41368353884e419c2118404ffc Mon Sep 17 00:00:00 2001 From: Joris <j.r.j.lelieveld@students.uu.nl> Date: Sun, 23 May 2021 16:59:13 +0200 Subject: [PATCH] Added some comments --- aql/convertQuery.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/aql/convertQuery.go b/aql/convertQuery.go index 1e6c635..5d529b7 100644 --- a/aql/convertQuery.go +++ b/aql/convertQuery.go @@ -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 - numEntities := len(JSONQuery.Entities) - 1 - // How many relations there are - numRelations := len(JSONQuery.Relations) - 1 + // The largest possible id for an entity + largestEntityId := len(JSONQuery.Entities) - 1 + // The largest possible id for a relation + largestRelationId := 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 > numEntities || e < 0 { + if e > largestEntityId || 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 > numEntities || r.EntityTo > numEntities { + if r.EntityFrom > largestEntityId || r.EntityTo > largestEntityId { 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 > numRelations || r < 0 { + if r > largestRelationId || r < 0 { return nil, errors.New("non-existing relation referenced in return") } } -- GitLab