final class PgSqlQueryGuard
Public API: explicitly declared with @visibility public.

Classifies PostgreSQL SQL statements into QueryKind categories.

Route reads, simulated writes and transactionsdoctest
$guard = new \ZtdQuery\Platform\Postgres\Rewrite\PgSqlQueryGuard(new \ZtdQuery\Platform\Postgres\Sql\PgSqlParser());
    $guard->classify('SELECT 1') === \ZtdQuery\Rewrite\QueryKind::READ // => true
    $guard->classify('DELETE FROM users') === \ZtdQuery\Rewrite\QueryKind::WRITE_SIMULATED // => true
    $guard->classify('BEGIN') === \ZtdQuery\Rewrite\QueryKind::SKIPPED // => true
    $guard->classify('VACUUM') // => null

Methods§

public function __construct(PgSqlParser $parser)

Initializes the collaborators and state used by this query guard.

Parameters

public function classify(string $sql): ?QueryKind
Public API: explicitly declared with @visibility public.

Classify a SQL string into READ/WRITE_SIMULATED/DDL_SIMULATED/SKIPPED or null.

Parameters

$sqlstring

Returns

Route reads, simulated writes and transactionsdoctest
$guard = new \ZtdQuery\Platform\Postgres\Rewrite\PgSqlQueryGuard(new \ZtdQuery\Platform\Postgres\Sql\PgSqlParser());
    $guard->classify('SELECT 1') === \ZtdQuery\Rewrite\QueryKind::READ // => true
    $guard->classify('DELETE FROM users') === \ZtdQuery\Rewrite\QueryKind::WRITE_SIMULATED // => true
    $guard->classify('BEGIN') === \ZtdQuery\Rewrite\QueryKind::SKIPPED // => true
    $guard->classify('VACUUM') // => null
Test cases 45
Called from 1
Calls 6

Private surface 1§

Implementation details, listed for orientation only.

private PgSqlParser $parser

Test cases 182§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 35
Other tests reaching this symbol 147

Relations§

Instantiated in 1
Method calls 1
Type declarations 4