[4.x] Add charset and collation support to PostgreSQLDatabaseManager #1429
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.
Problem
The
PostgreSQLDatabaseManagercreates tenant databases without specifying encoding, unlikeMySQLDatabaseManagerwhich 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:WIN1252encodingLATIN1or other regional encodingsThis 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
MySQLDatabaseManagerby reading thecharsetvalue from the database connection configuration and applying them when creating tenant databases.Changes
charsetvalue from the connection configENCODINGparameter to the CREATE DATABASE statementConfiguration
Users can now control the encoding via their
config/database.php:Notes