-
Notifications
You must be signed in to change notification settings - Fork 3
dawgs Version 2 #10
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
zinic
wants to merge
2
commits into
main
Choose a base branch
from
v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
dawgs Version 2 #10
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package database | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/specterops/dawgs/graph" | ||
|
||
"github.com/specterops/dawgs/cypher/models/cypher" | ||
) | ||
|
||
type Option int | ||
|
||
const ( | ||
OptionReadOnly Option = 0 | ||
OptionReadWrite Option = 1 | ||
) | ||
|
||
type Result interface { | ||
HasNext(ctx context.Context) bool | ||
Scan(scanTargets ...any) error | ||
Error() error | ||
Close(ctx context.Context) error | ||
|
||
// Values returns the next values array from the result. | ||
// | ||
// Deprecated: This function will be removed in future version. | ||
Values() []any | ||
} | ||
|
||
type Driver interface { | ||
WithGraph(target Graph) Driver | ||
|
||
// Eventually to be deprecated - this is currently a translation gap where cysql doesn't correctly | ||
// marshal create statements | ||
// | ||
// Deprecated: This function will be removed in future version. | ||
CreateNode(ctx context.Context, node *graph.Node) (graph.ID, error) | ||
|
||
// Eventually to be deprecated - this is currently a translation gap where cysql doesn't correctly | ||
// marshal create statements | ||
// | ||
// Deprecated: This function will be removed in future version. | ||
CreateRelationship(ctx context.Context, relationship *graph.Relationship) (graph.ID, error) | ||
|
||
Exec(ctx context.Context, query *cypher.RegularQuery, parameters map[string]any) Result | ||
Explain(ctx context.Context, query *cypher.RegularQuery, parameters map[string]any) Result | ||
Profile(ctx context.Context, query *cypher.RegularQuery, parameters map[string]any) Result | ||
|
||
// Mapper is supporting backward compat for v1 | ||
// | ||
// Deprecated: This function will be removed in future version. | ||
Mapper() graph.ValueMapper | ||
} | ||
|
||
type QueryLogic func(ctx context.Context, driver Driver) error | ||
|
||
type Instance interface { | ||
AssertSchema(ctx context.Context, schema Schema) error | ||
Session(ctx context.Context, driverLogic QueryLogic, options ...Option) error | ||
Transaction(ctx context.Context, driverLogic QueryLogic, options ...Option) error | ||
Close(ctx context.Context) error | ||
|
||
// FetchKinds retrieves the complete list of kinds available to the database. | ||
FetchKinds(ctx context.Context) (graph.Kinds, error) | ||
} | ||
|
||
type errorResult struct { | ||
err error | ||
} | ||
|
||
func (s errorResult) HasNext(ctx context.Context) bool { | ||
return false | ||
} | ||
|
||
func (s errorResult) Scan(scanTargets ...any) error { | ||
return s.err | ||
} | ||
|
||
func (s errorResult) Error() error { | ||
return s.err | ||
} | ||
|
||
func (s errorResult) Values() []any { | ||
return nil | ||
} | ||
|
||
func (s errorResult) Close(ctx context.Context) error { | ||
return nil | ||
} | ||
|
||
func NewErrorResult(err error) Result { | ||
return errorResult{ | ||
err: err, | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Pass testCtx to dawgs.Open instead of context.TODO()
Use the test’s cancellable context so open/handshakes honor deadlines/cancellation hooks, consistent with the rest of the test.
Apply this diff:
Run this to double-check config fields and driver symbol existence:
🏁 Script executed:
Length of output: 2303
Use testCtx when opening the DB connection (replace context.TODO())
Use the test’s cancellable context so open/handshakes honor deadlines/cancellation hooks. Verified: dawgs.Open accepts a context and dawgs.Config contains GraphQueryMemoryLimit and ConnectionString; pg.DriverName exists.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents