-
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
[9.x] Fix parsing config('database.connections.pgsql.search_path')
#41088
Merged
taylorotwell
merged 1 commit into
laravel:9.x
from
derekmd:postgresql-parse-search-path-fix
Feb 17, 2022
Merged
[9.x] Fix parsing config('database.connections.pgsql.search_path')
#41088
taylorotwell
merged 1 commit into
laravel:9.x
from
derekmd:postgresql-parse-search-path-fix
Feb 17, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The given PostgresConnector regex doesn't consider the full range of characters allowed in a schema or variable name - specifically '-' and accented characters. e.g., 'test-db' was being parsed as `set search_path to "test", "db"` instead of `set search_path to "test-db"` Replace the 'search_path' regex allowlist of characters with a blocklist of delimiters when config('database.connections.pgsql.search_path') is a string value. Technically Postgres _does_ allow our config delimiter characters (spaces, comma, quotes) in symbols so an array configuration can instead be used for such schema names. However single/double quote characters in such array configs aren't supported. --- * Roll methods testPostgresSearchPathCommaSeparatedValueSupported() & testPostgresSearchPathVariablesSupported() into testPostgresSearchPathIsSet() with the provideSearchPaths() data set. * testPostgresSearchPathArraySupported() is repurposed to show config('database.connections.pgsql.schema') from versions < 9.x is used when the 'search_path' config key is absent. * Fix PostgresConnector::quoteSearchPath() docblock since passing in a string value would throw an exception for being un-Countable. Its only use is being given parseSearchPath()'s return value which is an array.
derekmd
force-pushed
the
postgresql-parse-search-path-fix
branch
from
February 17, 2022 21:51
e1a9467
to
eff2a00
Compare
Thanks! |
derekmd
added a commit
to derekmd/framework
that referenced
this pull request
Feb 24, 2022
….search_path')` 1. `PostgresBuilder::parseSchemaAndTable()` Needs a fallback to <= 8.x `config('database.connections.pgsql.schema')` when 9.x renamed `config('database.connections.pgsql.search_path')` is missing. 2. `PostgresBuilder::getAllTables()` + `getAllViews()` + `parseSchemaAndTable()` Apply the `parseSearchPath()` fixes applied to PostgresConnector: laravel#41088 3. `PostgresBuilder::parseSchemaAndTable()` Remove duplicate `$user` variable `config('database.connections.pgsql.username')` replacement handling already done by `parseSearchPath()`. 4. `DatabasePostgresBuilderTest` Add more test cases and use terse method names instead of extensive comments to concisely communicate each case.
derekmd
added a commit
to derekmd/framework
that referenced
this pull request
Feb 24, 2022
….search_path')` 1. `PostgresBuilder::parseSchemaAndTable()` * Needs a fallback to <= 8.x `config('database.connections.pgsql.schema')` when 9.x renamed `config('database.connections.pgsql.search_path')` is missing. * Remove duplicate `$user` variable `config('database.connections.pgsql.username')` replacement handling already done by `parseSearchPath()`. 2. `PostgresBuilder::getAllTables()` + `getAllViews()` + `parseSchemaAndTable()` Apply the `parseSearchPath()` fixes applied to PostgresConnector: laravel#41088 3. `DatabasePostgresBuilderTest` Add more test cases and use terse method names instead of extensive comments to concisely communicate each case.
derekmd
added a commit
to derekmd/framework
that referenced
this pull request
Feb 24, 2022
….search_path')` 1. `PostgresBuilder::parseSchemaAndTable()` * Needs a fallback to <= 8.x `config('database.connections.pgsql.schema')` when 9.x renamed `config('database.connections.pgsql.search_path')` is missing. * Remove duplicate `$user` variable `config('database.connections.pgsql.username')` replacement handling already done by `parseSearchPath()`. 2. `PostgresBuilder::getAllTables()` + `getAllViews()` + `parseSchemaAndTable()` Apply the `parseSearchPath()` fixes applied to PostgresConnector: laravel#41088 3. `DatabasePostgresBuilderTest` Add more test cases and use terse method names instead of extensive comments to concisely communicate each case.
derekmd
added a commit
to derekmd/framework
that referenced
this pull request
Feb 24, 2022
….search_path')` 1. `PostgresBuilder::parseSchemaAndTable()` * Needs a fallback to <= 8.x `config('database.connections.pgsql.schema')` when 9.x renamed `config('database.connections.pgsql.search_path')` is missing. * Remove duplicate `$user` variable `config('database.connections.pgsql.username')` replacement handling already done by `parseSearchPath()`. 2. `PostgresBuilder::getAllTables()` + `getAllViews()` + `parseSchemaAndTable()` Apply the `parseSearchPath()` fixes applied to PostgresConnector: laravel#41088 3. `DatabasePostgresBuilderTest` Add more test cases and use terse method names instead of extensive comments to concisely communicate each case.
derekmd
added a commit
to derekmd/framework
that referenced
this pull request
Feb 24, 2022
….search_path')` 1. `PostgresBuilder::parseSchemaAndTable()` * Needs a fallback to <= 8.x `config('database.connections.pgsql.schema')` when 9.x renamed `config('database.connections.pgsql.search_path')` is missing. * Remove duplicate `$user` variable `config('database.connections.pgsql.username')` replacement handling already done by `parseSearchPath()`. 2. `PostgresBuilder::getAllTables()` + `getAllViews()` + `parseSchemaAndTable()` Apply the `parseSearchPath()` fixes applied to PostgresConnector: laravel#41088 3. `DatabasePostgresBuilderTest` Add more test cases and use terse method names instead of extensive comments to concisely communicate each case.
taylorotwell
pushed a commit
that referenced
this pull request
Feb 24, 2022
….search_path')` (#41215) 1. `PostgresBuilder::parseSchemaAndTable()` * Needs a fallback to <= 8.x `config('database.connections.pgsql.schema')` when 9.x renamed `config('database.connections.pgsql.search_path')` is missing. * Remove duplicate `$user` variable `config('database.connections.pgsql.username')` replacement handling already done by `parseSearchPath()`. 2. `PostgresBuilder::getAllTables()` + `getAllViews()` + `parseSchemaAndTable()` Apply the `parseSearchPath()` fixes applied to PostgresConnector: #41088 3. `DatabasePostgresBuilderTest` Add more test cases and use terse method names instead of extensive comments to concisely communicate each case.
taylorotwell
pushed a commit
to illuminate/database
that referenced
this pull request
Feb 24, 2022
….search_path')` (#41215) 1. `PostgresBuilder::parseSchemaAndTable()` * Needs a fallback to <= 8.x `config('database.connections.pgsql.schema')` when 9.x renamed `config('database.connections.pgsql.search_path')` is missing. * Remove duplicate `$user` variable `config('database.connections.pgsql.username')` replacement handling already done by `parseSearchPath()`. 2. `PostgresBuilder::getAllTables()` + `getAllViews()` + `parseSchemaAndTable()` Apply the `parseSearchPath()` fixes applied to PostgresConnector: laravel/framework#41088 3. `DatabasePostgresBuilderTest` Add more test cases and use terse method names instead of extensive comments to concisely communicate each case.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #41062
e.g., Config value
'test-db'
was being parsed asset search_path to "test", "db"
instead ofset search_path to "test-db"
9.x renamed
config('database.connections.pgsql.schema')
toconfig('database.connections.pgsql.search_path')
and introduced special handling if the config value is a string containing many segments. The originating PR has some examples. However the givenPostgresConnector
regex doesn't consider the full range of characters allowed in a schema or variable name - specifically'-'
and accented characters.Replace the
'search_path'
regex alphanumeric-only allowlist of characters with a blocklist of delimiters whenconfig('database.connections.pgsql.search_path')
is a string value. Technically Postgres does allow our config delimiter characters (spaces, comma, quotes) in symbols so an array configuration can instead be used for such schema names. (However non-wrapping single/double quote characters in such array configs still aren't supported.)testPostgresSearchPathCommaSeparatedValueSupported()
&testPostgresSearchPathVariablesSupported()
intotestPostgresSearchPathIsSet()
with the fuller coverageprovideSearchPaths()
data set.testPostgresSearchPathArraySupported()
is repurposed to showconfig('database.connections.pgsql.schema')
from versions < 9.x is used when the'search_path'
config key is absent.PostgresConnector::quoteSearchPath()
parameter docblock since passing in a string value would throw an exception for being un-Countable
. Its only use is being passedparseSearchPath()
's return value which is an array.