Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database connection #1022

Open
Trylam opened this issue Oct 16, 2024 · 4 comments
Open

Database connection #1022

Trylam opened this issue Oct 16, 2024 · 4 comments
Labels
Milestone

Comments

@Trylam
Copy link

Trylam commented Oct 16, 2024

Description

I've created a cakephp 5 project with a postgresql database. I configured the database as usual and got this error message : CakePHP is NOT able to connect to the database.
SQLSTATE[22023]: Invalid parameter value: 7 ERREUR: valeur invalide pour le paramètre « client_encoding » : « utf8mb4 »

To solve the problem, we had to comment out the line in app.php : 'encoding' => 'utf8mb4',
and I don't think it's right that the cakephp system encourages you to use a MariaDB/MySQL database instead of another one. I think that this field should be commented out by default and that it should be up to MariaDB/MySQL users to uncomment it.

CakePHP Version

5.1.1

PHP Version

No response

@Trylam Trylam added the Defect label Oct 16, 2024
@ADmad ADmad transferred this issue from cakephp/cakephp Oct 16, 2024
@ADmad
Copy link
Member

ADmad commented Oct 16, 2024

Pretty sure MySQL/MariaDB is the most widely used database, so providing default config for it makes things a tad bit easier for users.

The issue is due to the fact that the default datasource config exists in both app.php and app_local.php (generated at project creation time). The driver and encoding is specified in app.php but not in app_local.php. Moving all datasource config to app_local.php would avoid such gotachas.

@ADmad ADmad added this to the 5.x milestone Oct 16, 2024
@dereuromark
Copy link
Member

Moving all datasource config to app_local.php would avoid such gotachas.

Having the main (and for all drivers valid) config in app would still be a bit more DRY.
To have local file only needed for actual things to overwrite (and usually specific to env).

@HumanG33k
Copy link

Can that specific value should not be set by default one "lvl down" (driver or whatever) with the most valid value (utf8mb4). And let it appear in local env file as comment in order to let know people need to change it the option exist.

@dereuromark
Copy link
Member

dereuromark commented Oct 16, 2024

This would revert #1011
I am fine with it, if there is people really bothered by it.
At the time it seemed like a good default for the majority - since many use Mysql etc directly in their apps.

The downside of it would be: It will for many not be clear they are silently using utf8 connection.
You get a clear error message and know how to fix things, the other direction usually not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants