Skip to content

Feature/add mis endpoints in query #696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

bluepal-prasanthi-moparthi
Copy link
Collaborator

This includes the following Query-related endpoints:

  1. GET - _db/{database-name}/_api/query/properties
  2. PUT - _db/{database-name}/_api/query/properties
  3. GET - _db/{database-name}/_api/query/current
  4. GET - _db/{database-name}/_api/query/slow
  5. DELETE - _db/{database-name}/_api/query/slow
  6. DELETE - _db/{database-name}/_api/query/{query-id}
  7. GET - _db/{database-name}/_api/query/rules
  8. GET - _db/{database-name}/_api/query-plan-cache
  9. DELETE - _db/{database-name}/_api/query-plan-cache
  10. GET - _db/{database-name}/_api/query-cache/entries
  11. DELETE - _db/{database-name}/_api/query-cache
  12. GET - _db/{database-name}/_api/query-cache/properties
  13. PUT - _db/{database-name}/_api/query-cache/properties
  14. POST - _db/{database-name}/_api/aqlfunction
  15. DELETE - _db/{database-name}/_api/aqlfunction/{name}
  16. GET - _db/{database-name}/_api/aqlfunction

@bluepal-prasanthi-moparthi bluepal-prasanthi-moparthi force-pushed the feature/add_mis_endpoints_in_query branch from 02974e4 to f6a6c13 Compare August 6, 2025 11:57
@jwierzbo jwierzbo requested a review from Copilot August 7, 2025 07:14
Copilot

This comment was marked as outdated.

@jwierzbo jwierzbo requested a review from Copilot August 14, 2025 12:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive query-related endpoints to the ArangoDB Go driver v2, implementing 16 missing API endpoints for query management and user-defined functions. The implementation provides full query system control including properties management, query monitoring, caching, optimization rules, and user-defined function operations.

  • Adds query properties management endpoints (GET/PUT)
  • Implements query monitoring and control endpoints (current/slow queries, kill operations)
  • Adds query caching and plan cache management endpoints
  • Includes optimizer rules and user-defined function endpoints

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
v2/utils/type.go Adds ToJSONString utility function for JSON formatting
v2/tests/database_query_test.go Comprehensive test suite for all new query endpoints
v2/arangodb/utils.go Adds RequiredFieldError helper function
v2/arangodb/database_query_impl.go Complete implementation of all 16 query endpoints
v2/arangodb/database_query.go Interface definitions and data structures for query endpoints
v2/CHANGELOG.md Documents the addition of missing query endpoints

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

}

func (d databaseQuery) KillAQLQuery(ctx context.Context, queryId string, all *bool) error {
return d.deleteQueryEndpoint(ctx, path.Join("_api/query", queryId), all)
Copy link
Preview

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path.Join function is inappropriate for URL construction. It uses OS-specific path separators which could cause issues on Windows. Use strings.Join or manual string concatenation instead.

Suggested change
return d.deleteQueryEndpoint(ctx, path.Join("_api/query", queryId), all)
return d.deleteQueryEndpoint(ctx, "_api/query/" + queryId, all)

Copilot uses AI. Check for mistakes.


// If still empty, check if the feature is supported
if len(resp) == 0 {
t.Logf("Query plan cache is empty. This might be because:")
Copy link
Preview

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message contains 'Query plan cache' but should be 'Query entries cache' to match the context of the test function Test_GetQueryEntriesCache.

Suggested change
t.Logf("Query plan cache is empty. This might be because:")
t.Logf("Query entries cache is empty. This might be because:")

Copilot uses AI. Check for mistakes.

// If still empty, check if the feature is supported
if len(resp) == 0 {
t.Logf("Query plan cache is empty. This might be because:")
t.Logf("1. Query query entries caching is disabled in ArangoDB configuration")
Copy link
Preview

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message contains redundant 'Query query entries' and should be 'Query entries caching is disabled in ArangoDB configuration'.

Suggested change
t.Logf("1. Query query entries caching is disabled in ArangoDB configuration")
t.Logf("1. Query entries caching is disabled in ArangoDB configuration")

Copilot uses AI. Check for mistakes.


resp, err := connection.CallDelete(ctx, d.db.connection(), url, &response, d.db.modifiers...)
if err != nil {
return utils.NewType(0), err
Copy link
Preview

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When an error occurs during the HTTP call, returning utils.NewType(0) masks the actual error condition. Consider returning nil instead to indicate no deletion count is available due to the error.

Suggested change
return utils.NewType(0), err
return nil, err

Copilot uses AI. Check for mistakes.

case http.StatusOK, http.StatusCreated:
return response.DeletedCount, nil
default:
return utils.NewType(0), response.AsArangoErrorWithCode(code)
Copy link
Preview

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a non-success HTTP status is returned, returning utils.NewType(0) provides misleading information that 0 functions were deleted. Consider returning nil to indicate the operation failed.

Suggested change
return utils.NewType(0), response.AsArangoErrorWithCode(code)
return nil, err
}
switch code := resp.Code(); code {
case http.StatusOK, http.StatusCreated:
return response.DeletedCount, nil
default:
return nil, response.AsArangoErrorWithCode(code)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant