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

Breaking Postgres custom options change #54193

Closed
leigeber opened this issue Jan 14, 2025 · 4 comments
Closed

Breaking Postgres custom options change #54193

leigeber opened this issue Jan 14, 2025 · 4 comments
Labels

Comments

@leigeber
Copy link
Contributor

leigeber commented Jan 14, 2025

Laravel Version

11.38.1

PHP Version

8.4.2

Database Driver & Version

PostgreSQL 16.4

Description

It seems that a change in #54101 is breaking the documented approach from https://laravel.com/docs/11.x/database we've been using to pass in custom Postgres options.

This is what we've been doing.

'connections' => [
	'app' => [
		'driver' => 'pgsql',
		'host' => env('DB_HOST', 'localhost'),
		'port' => env('DB_PORT', '5432'),
		'database' => env('DB_DATABASE'),
		'username' => env('DB_USERNAME'),
		'password' => env('DB_PASSWORD', ''),
		'prefix' => '',
		'prefix_indexes' => true,
		'search_path' => 'public',
		'charset' => 'utf8',
		'options' => [
			PDO::ATTR_EMULATE_PREPARES => true,
			PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
			PDO::ATTR_PERSISTENT => true
		]
	]
]

In PostgresConnector.php $dsn .= ";{$option}={$config[$option]}"; our options array is coming through and throwing an "Array to string conversion" ErrorException.

Basically "options" being added to that predefined array of allowed options seems wrong, since that's been a reserved key to pass through options. To that point, I'm not sure what the pull request is solving since you could already pass in any custom option, but could be there's a different purpose there.

Steps To Reproduce

Add custom options to your Postgres database config and attempt a connection.

@crynobone
Copy link
Member

Hi there,

#54101 should only affect Laravel Framework 11 and your Laravel version is 10.38.1?

@leigeber
Copy link
Contributor Author

Sorry about that @crynobone. I'm on 11.38.1. Updated in the original issue.

@crynobone
Copy link
Member

Breaking changes reverted in 11.38.2

@Maniload
Copy link
Contributor

Hey @leigeber, sorry that my pull request ended up being a breaking change. I explained my use-case in this discussion: #53412

To that point, I'm not sure what the pull request is solving since you could already pass in any custom option, but could be there's a different purpose there.

I was wondering if that is possible, but I couldn't get it to work. If you could show me how to do it, I would be very thankful.

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

3 participants