Skip to content

Breaking Postgres custom options change #54193

@leigeber

Description

@leigeber

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions