feat: structured database connection config (#39)#40
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds structured database connection configuration as an alternative to URL-based connection strings, closing issue #39. Users can now specify host, port, user, password, name, and options fields directly, avoiding URL-encoding issues with special characters in passwords. Connections are built using driver-native APIs (PostgreSQL key-value DSN, MySQL OptsBuilder).
Changes:
- New discrete connection fields on
DatabaseConfigwith mutual exclusivity validation againsturl/url_env - Driver-specific structured connection logic: PostgreSQL key-value DSN builder and MySQL
OptsBuilderintegration, with SQLite explicitly rejected - Comprehensive tests (unit + integration), documentation, and an example spec file
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/seed/schema.rs | Adds structured fields to DatabaseConfig, validation, and has_structured_config() helper; moves URL resolution out of SeedPlan |
| src/seed/db.rs | Refactors connect() to accept DatabaseConfig, adds connect_structured(), build_postgres_dsn(), escape_dsn_value(), and unsupported_driver_error() |
| src/seed/mod.rs | Updates call site to pass &plan.database instead of a resolved URL string |
| docs/seeding.md | Documents both connection styles, field reference table, and resolution order |
| examples/seed/structured-config-seed.yaml | Example spec using structured config with templated password |
| tests/input/seed-postgres-structured.yaml | Integration test fixture for PostgreSQL structured config |
| tests/input/seed-mysql-structured.yaml | Integration test fixture for MySQL structured config |
| tests/integration_test.rs | Two new integration tests verifying structured config with real databases |
| CHANGELOG.md | Documents the new feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… URL (#39) Add discrete connection fields (host, port, user, password, name, options) as an alternative to url/url_env. Connections are built using driver-native APIs (PostgreSQL key-value DSN, MySQL OptsBuilder), bypassing URL parsing so passwords with special characters work without encoding. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MySQL's OptsBuilder does not support arbitrary key-value connection parameters. Return an error listing the unsupported keys instead of silently ignoring them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c5f483e to
0edbdcd
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
host,port,user,password,name,options) toDatabaseConfigas an alternative tourl/url_envOptsBuilder), bypassing URL parsing entirely — passwords with@,%,:etc. work without encodingurl/url_envcannot be combinedCloses #39
Test plan
test_seed_postgres_structured_config,test_seed_mysql_structured_config)cargo clippy -- -D warningscleancargo fmt -- --checkclean🤖 Generated with Claude Code