Skip to content
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

Add GqlStatusObject support as notifications to ResultSummary #588

Merged
merged 18 commits into from
Jul 24, 2024

Conversation

StephenCathcart
Copy link
Contributor

@StephenCathcart StephenCathcart commented Jun 26, 2024

⚠️ This API is released as preview.

Introduces GQL-compliant status objects to the ResultSummary.

GqlStatusObject is a GQL-compliant Notification object and status of query execution, this new object includes GqlStatus and StatusDescription.

ResultSummary.GqlStatusObjects() always contains at least 1 status representing the Success, No Data or Omitted Result.

The GqlStatusObjects will be presented in the following order:

  • A “no data” (02xxx) has precedence over a warning;
  • A warning (01xxx) has precedence over a success.
  • A success (00xxx) has precedence over anything informational (03xxx)

Migration from Notification

Most properties in Notification exist in the new GqlStatusObject, except Code and Title.
The GqlStatusObject.GqlStatus is equivalent to Code in Notification, but with values compliant with GQL.
The properties GqlStatusObject.Classification and GqlStatusObject.RawClassification are equivalent to Notification.Category and Notification.RawCategory. The name change is needed because Category has a different meaning in GQL.

Usage

Disabling GqlStatusObjects can be done in the same way as disabling Notifications. However, non-notification status can not be filtered (such as Success or No Data):

neo4j.NewDriverWithContext("neo4j://localhost", neo4j.BasicAuth("neo4j", "password", ""), func(config *config.Config) {
    config.NotificationsDisabledClassifications = notifications.DisableClassifications(notifications.Deprecation, notifications.Performance)
})

Iterating through GqlStatusObjects is also done in the same way as Notifications:

gqlStatusObjects := result.Summary.GqlStatusObjects()
for _, gqlStatusObject := range gqlStatusObjects {
    fmt.Printf(gqlStatusObject.GqlStatus())
    fmt.Printf(gqlStatusObject.StatusDescription())
    fmt.Printf(gqlStatusObject.DiagnosticRecord())
    // and so on
}

Deprecations

  • neo4j.NotificationSeverity please use notifications.NotificationSeverity directly.

  • neo4j.Warning please use notifications.Warning directly.

  • neo4j.Information please use notifications.Information directly.

  • neo4j.UnknownSeverity please use notifications.UnknownSeverity directly.

  • neo4j.NotificationCategory please use notifications.NotificationCategory directly.

  • neo4j.Hint please use notifications.Hint directly.

  • neo4j.Unrecognized please use notifications.Unrecognized directly.

  • neo4j.Unsupported please use notifications.Unsupported directly.

  • neo4j.Performance please use notifications.Performance directly.

  • neo4j.Deprecation please use notifications.Deprecation directly.

  • neo4j.Generic please use notifications.Generic directly.

  • neo4j.Security please use notifications.Security directly.

  • neo4j.Topology please use notifications.Topology directly.

  • neo4j.UnknownCategory please use notifications.Unknown directly.

@StephenCathcart StephenCathcart marked this pull request as ready for review July 2, 2024 05:01
@StephenCathcart
Copy link
Contributor Author

@robsdedude robsdedude self-requested a review July 5, 2024 11:33
neo4j/config/driver.go Outdated Show resolved Hide resolved
neo4j/config_test.go Show resolved Hide resolved
neo4j/db/summary.go Show resolved Hide resolved
neo4j/db/summary.go Show resolved Hide resolved
neo4j/db/summary.go Outdated Show resolved Hide resolved
neo4j/notifications/notifications.go Outdated Show resolved Hide resolved
neo4j/notifications/notifications.go Outdated Show resolved Hide resolved
testkit-backend/2cypher.go Outdated Show resolved Hide resolved
testkit-backend/backend.go Outdated Show resolved Hide resolved
testkit-backend/backend.go Outdated Show resolved Hide resolved
@StephenCathcart
Copy link
Contributor Author

@StephenCathcart StephenCathcart merged commit f49845b into neo4j:5.0 Jul 24, 2024
5 checks passed
@StephenCathcart StephenCathcart deleted the feat/gql-errors branch July 24, 2024 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants