Skip to content

v0.2.2

Choose a tag to compare

@yuku yuku released this 30 Jul 04:21
· 1 commit to main since this release
4aeed44

Features

Database Owner Configuration

  • New: Add DatabaseOwner field 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/pgconst package
  • API: Export pgconst.IsValidPostgreSQLIdentifier for reusability
  • Constants: Add MaxIdentifierLength constant 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:

  1. Connection user must be a member of the DatabaseOwner role, OR
  2. Connection user must have superuser privileges, OR
  3. 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