-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Laravel 9, Postgres can't change search_path to valid schema #41062
Comments
Character framework/src/Illuminate/Database/Connectors/PostgresConnector.php Lines 127 to 133 in 171f65d
It looks preg_match_all('/[a-zA-z0-9$]{1,}/i', 'test-db', $matches);
$matches;
// [
// [
// "test",
// "db",
// ],
// ] which should be Funnily enough, preg_match_all('/[a-zA-z0-9$]{1,}/i', 'test_db', $matches);
$matches;
// [
// [
// "test_db",
// ],
// ] Regex Edit: Yup, According the originating PR's examples, a naive negating regex might be the easiest solution for parsing the config string: preg_match_all('/[^\s,"\']+/', $searchPath, $matches); |
This is also funny because, according to this code, when I pass search_path as array it will work - which looks like a nice workaround temporarily. But.... also looking at method below
It looks potentially buggy. It uses count($searchPath) and according to phpdoc @param array|string $searchPath. So, if string is passed it will throw Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, string given. I see that configureSearchPath first uses parseSearchPath, but if so then $searchPath should be typehinted to array. |
@derekmd can you maybe PR that? |
Description:
I am trying to change the search_path to the current schema and unfortunately neither queries nor migrations work. Laravel fails to connect to the database on the defined schema.
Steps To Reproduce:
'search_path' => 'test-db',
dd(DB::getPdo()->query('select current_schemas(true)')->fetchAll());
The text was updated successfully, but these errors were encountered: