Skip to content

fix(dawgrun): select or init default graph on db connect#78

Merged
seanjSO merged 1 commit into
mainfrom
seanj/dawgrun-graph-schema
May 13, 2026
Merged

fix(dawgrun): select or init default graph on db connect#78
seanjSO merged 1 commit into
mainfrom
seanj/dawgrun-graph-schema

Conversation

@seanjSO
Copy link
Copy Markdown
Contributor

@seanjSO seanjSO commented May 12, 2026

Description

Update dawgrun connection creation to select or create a default (or, named) graph when opening connection

Resolves: <TICKET_OR_ISSUE_NUMBER>

Type of Change

  • Chore (a change that does not modify the application functionality)
  • Bug fix (a change that fixes an issue)
  • New feature / enhancement (a change that adds new functionality)
  • Refactor (no behaviour change)
  • Test coverage
  • Build / CI / tooling
  • Documentation

Testing

  • Unit tests added / updated
  • Integration tests added / updated
  • Full test suite run (make test_all with CONNECTION_STRING set)

Screenshots (if appropriate):

Driver Impact

  • PostgreSQL driver (drivers/pg)
  • Neo4j driver (drivers/neo4j)

Checklist

  • Code is formatted
  • All existing tests pass
  • go.mod / go.sum are up to date if dependencies changed

Summary by CodeRabbit

  • New Features
    • Added --default-graph flag to specify the default graph name for database connections (defaults to "default")
    • Added --init-graph flag to enable automatic schema initialization when the default graph setup fails
    • Improved connection initialization to attempt setting the default graph and optionally initialize schema on failure

Review Change Stack

@seanjSO seanjSO self-assigned this May 12, 2026
@seanjSO seanjSO added bug Something isn't working go Pull requests that update go code labels May 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Warning

Rate limit exceeded

@seanjSO has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 24 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dfaed717-616a-4160-8425-b61ad737d5e1

📥 Commits

Reviewing files that changed from the base of the PR and between a377ebb and c472f37.

📒 Files selected for processing (1)
  • tools/dawgrun/pkg/commands/db.go

Walkthrough

The open command in db.go gains two new command-line flags: --default-graph (defaults to "default") and --init-graph (boolean). After establishing a database connection, the command attempts to set the named default graph, and if that fails with --init-graph enabled, it initializes the graph schema via querier.AssertSchema.

Changes

Default graph initialization

Layer / File(s) Summary
Default graph initialization flags and logic
tools/dawgrun/pkg/commands/db.go
Flag definitions for --default-graph and --init-graph are registered on the command's flagSet and reset to defaults in ClearFlagsFn. After opening the database connection, querier.SetDefaultGraph is called with the provided graph name; if it fails and --init-graph is enabled, querier.AssertSchema is called to initialize the schema, otherwise the error is returned.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit whispers through the dawn so bright,
"With graphs unnamed, we'll set things right!"
Two flags now dance where defaults play,
And schemas bloom when needed today. 🐰✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description addresses the main change but lacks critical details: the ticket/issue number is unresolved, and no testing was performed or verified per the checklist. Resolve the ticket reference and confirm which testing was performed (unit, integration, or full suite) by checking appropriate boxes in the Testing section.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding functionality to select or initialize a default graph when connecting to the database.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch seanj/dawgrun-graph-schema

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@seanjSO seanjSO requested a review from zinic May 12, 2026 19:12
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tools/dawgrun/pkg/commands/db.go (1)

70-70: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Reset all flag variables for consistency.

Only driverOverride is reset before parsing flags, but defaultGraphName and initGraphOnFail are not. This creates an inconsistent pattern and reduces defensive safety in case ClearFlagsFn is not invoked.

🔧 Proposed fix to reset all flag variables
 		Fn: func(ctx *CommandContext, fields []string) error {
 			driverOverride = ""
+			defaultGraphName = "default"
+			initGraphOnFail = false
 			if err := flagSet.Parse(fields); err != nil {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/dawgrun/pkg/commands/db.go` at line 70, Reset the remaining flag state
variables alongside driverOverride before flag parsing: ensure defaultGraphName
and initGraphOnFail are explicitly reset (e.g., set to "" and false
respectively) in the same initialization block where driverOverride is set so
flag parsing starts from a known, consistent state; update the same function
that currently sets driverOverride (and document/align with ClearFlagsFn if
present) to include these resets referencing the variables defaultGraphName and
initGraphOnFail.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tools/dawgrun/pkg/commands/db.go`:
- Around line 64-67: The ClearFlagsFn currently resets driverOverride and
defaultGraphName but forgets to reset the initGraphOnFail boolean, causing its
value to persist across REPL commands; update the ClearFlagsFn to also
reinitialize initGraphOnFail (set it back to its default, e.g., false) alongside
resetting driverOverride and defaultGraphName so every command invocation starts
with the expected flag state.

---

Outside diff comments:
In `@tools/dawgrun/pkg/commands/db.go`:
- Line 70: Reset the remaining flag state variables alongside driverOverride
before flag parsing: ensure defaultGraphName and initGraphOnFail are explicitly
reset (e.g., set to "" and false respectively) in the same initialization block
where driverOverride is set so flag parsing starts from a known, consistent
state; update the same function that currently sets driverOverride (and
document/align with ClearFlagsFn if present) to include these resets referencing
the variables defaultGraphName and initGraphOnFail.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2b5e4c9b-fa90-4550-89de-750125f649b1

📥 Commits

Reviewing files that changed from the base of the PR and between ae5d313 and a377ebb.

📒 Files selected for processing (1)
  • tools/dawgrun/pkg/commands/db.go

Comment thread tools/dawgrun/pkg/commands/db.go
@seanjSO seanjSO force-pushed the seanj/dawgrun-graph-schema branch from a377ebb to c472f37 Compare May 12, 2026 19:17
Copy link
Copy Markdown
Contributor

@zinic zinic left a comment

Choose a reason for hiding this comment

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

:shipit:

@seanjSO seanjSO merged commit 0263a48 into main May 13, 2026
6 checks passed
@seanjSO seanjSO deleted the seanj/dawgrun-graph-schema branch May 13, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants