Skip to content

Conversation

@p1xel007
Copy link

@p1xel007 p1xel007 commented Jan 4, 2026

Problem

The PostgreSQLDatabaseManager creates tenant databases without specifying encoding, unlike MySQLDatabaseManager which respects the connection's charset configuration.

When encoding is not explicitly defined, PostgreSQL uses the server's default encoding (inherited from template0). This causes issues on systems where the default encoding differs from the application's expected encoding:

  • Windows systems often default to WIN1252 encoding
  • Some Linux configurations may use LATIN1 or other regional encodings
  • Docker containers may have different defaults depending on the base image

This mismatch leads to errors like:
SQLSTATE[22P05]: Untranslatable character: 7 ERROR: character with byte sequence 0xe2 0x86 0x92 in encoding "UTF8" has no equivalent in encoding "WIN1252"

Solution

Follow the same pattern as MySQLDatabaseManager by reading the charset value from the database connection configuration and applying them when creating tenant databases.

Changes

  • Read charset value from the connection config
  • Apply ENCODING parameter to the CREATE DATABASE statement

Configuration

Users can now control the encoding via their config/database.php:

'pgsql' => [
    // ...
    'charset' => 'UTF8',
],

Notes

  • Maintains consistency with
  • MySQLDatabaseManager.php
  • implementation
  • template0 is required (already in use) to allow encoding override
  • Backward compatible for users who already have charset configured

@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.93%. Comparing base (e3701f1) to head (3b0c1b0).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1429   +/-   ##
=========================================
  Coverage     85.92%   85.93%           
  Complexity     1147     1147           
=========================================
  Files           184      184           
  Lines          3360     3362    +2     
=========================================
+ Hits           2887     2889    +2     
  Misses          473      473           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant