Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-dir)"

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
Expand Down
26 changes: 26 additions & 0 deletions src/PostgresConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ final class PostgresConfig extends SqlConfig
'ssl_mode' => 'sslmode',
'sslMode' => 'sslmode',
'applicationName' => 'application_name',
'options' => 'options',
];

private ?string $connectionString = null;
Expand All @@ -42,6 +43,7 @@ public static function fromString(string $connectionString): self
$parts["db"] ?? null,
$parts["application_name"] ?? null,
$parts["sslmode"] ?? null,
$parts["options"] ?? null,
);
}

Expand All @@ -53,6 +55,7 @@ public function __construct(
?string $database = null,
private ?string $applicationName = null,
private ?string $sslMode = null,
private ?string $options = null,
) {
self::assertValidSslMode($sslMode);

Expand Down Expand Up @@ -115,6 +118,25 @@ public function withoutApplicationName(): self
return $new;
}

public function getOptions(): ?string
{
return $this->options;
}

public function withOptions(string $options): self
{
$new = clone $this;
$new->options = $options;
return $new;
}

public function withoutOptions(): self
{
$new = clone $this;
$new->options = null;
return $new;
}

/**
* @return string Connection string used with ext-pgsql and pecl-pq.
*/
Expand Down Expand Up @@ -152,6 +174,10 @@ public function getConnectionString(): string
$chunks[] = \sprintf("application_name='%s'", \addslashes($this->applicationName));
}

if ($this->options !== null) {
$chunks[] = \sprintf("options='%s'", \addslashes($this->options));
}

return $this->connectionString = \implode(" ", $chunks);
}
}
Loading