Repository navigation
v0.2.2
Features
Database Owner Configuration
- New: Add
DatabaseOwnerfield to Config struct for specifying database owner - Security: PostgreSQL identifier validation with SQL injection protection
- Compatibility: Maintains backward compatibility when DatabaseOwner is empty
Improvements
Code Organization
- Refactor: Move PostgreSQL utilities to
internal/pgconstpackage - API: Export
pgconst.IsValidPostgreSQLIdentifierfor reusability - Constants: Add
MaxIdentifierLengthconstant for better maintainability
Documentation
- Comprehensive: Detailed PostgreSQL permission requirements and setup patterns
- Examples: Code examples for development and production environments
- Troubleshooting: Common errors and solutions guide
Usage
config := &testdbpool.Config{
ID: "myapp-test",
Pool: connPool,
DatabaseOwner: "app_user", // Optional: specify database owner
SetupTemplate: setupFunc,
}Permission Requirements
When specifying a DatabaseOwner different from the connection user:
- Connection user must be a member of the DatabaseOwner role, OR
- Connection user must have superuser privileges, OR
- Connection user must have CREATEDB privilege at minimum
See the Database Owner Configuration section in README for detailed setup patterns.
Test Coverage
- Unit tests for Config validation and PostgreSQL identifier validation
- Integration tests verifying database ownership in real PostgreSQL environment
- Tests for various edge cases and error conditions
Breaking Changes
None - this release maintains full backward compatibility.
Full Changelog: v0.2.1...v0.2.2