Skip to content

Conversation

@tengfei8771
Copy link
Contributor

Enhance the behavior of obtaining default schema through database connection string by specifying the default schema through the SearchPath parameter in the connection string

…nection string by specifying the default schema through the SearchPath parameter in the connection string
@tengfei8771 tengfei8771 changed the base branch from main to release/6.0.0 April 23, 2025 08:31
/// </summary>
public static class PostgresqlExtensions
{
private static readonly string pattern= @"(?i)SearchPath=([^;]+)";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://www.postgresql.org/docs/current/ddl-schemas.html

Default search path would be:

"$user", public

Normally to customize search path one would use:

SET search_path TO myschema,public;

In both cases search path contains multiple schemas delimited by comma.

This regex does not seem to respect multiple schemas in search path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method only processes connection strings and does not support this parameter like 'search_path' in connection strings. If this parameter is not set, the database will default to reading public

/// </summary>
public static class PostgresqlExtensions
{
private static readonly string pattern= @"(?i)SearchPath=([^;]+)";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://www.npgsql.org/doc/connection-string-parameters.html parameter should be named "Search Path" and not "SearchPath"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common connection strings, like this
"Server=xxxx;Port=xxx;Database=xxx;User Id=xxxx;Password=xxxx;Pooling=false;Search Path=xxxx;IncludeErrorDetail=true;"
The schema parameters support SearchPath and Search Path and ignore case.
I modified the regular expression to support the above parameter types.

@droyad droyad changed the base branch from release/6.0.0 to main November 5, 2025 03:55
@droyad droyad merged commit d4f258e into DbUp:main Nov 5, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants