final class RelationsTarget
    implements PrivilegeTarget
    uses Snapshot
Public API: explicitly declared with @visibility public.

Relations or sequences named as the objects of a GRANT or REVOKE.

The word TABLE before relations is optional and always written back. Each relation is resolved against the context and its column privileges are checked (PG-GRANT-RELATION-001). A sequence is not resolved, since the server also creates sequences no statement declares (serial and identity columns); a name that resolves to a declaration of another kind is reported ("t" is not a sequence, PG-RELATION-KIND-001). Source: https://www.postgresql.org/docs/17/sql-grant.html.

Reading the table a privilege is granted ondoctest
$semantics = new \SqlSemantics\Platform\PostgreSql\Semantics();
    $table = $semantics->analyze('CREATE TABLE items (id int4, price int4)');
    $operation = $semantics->analyze('GRANT SELECT ON items TO joe', [$table]);
    $operation->facts->relation($operation->statement->target->relations[0])->table->table === $table->declarations()[0] // => true

Properties§

public non-empty-list<RelationReference> $relations

Methods§

public function __construct(
    public PrivilegeObjectKind $object,
    list<RelationReference> $relations,
)

Parameters

$objectPrivilegeObjectKindThe kind: relations or sequences
$relationslist<RelationReference>The relations in the order written, at least one, none limited with ONLY
Calls 5
public function object(): PrivilegeObjectKind

Answers the kind of the objects.

Test cases 1
public function deriveTarget(Derivation $derivation, array $privileges): void

Resolves each relation and checks its column privileges; sequences are not resolved.

Parameters

$derivationDerivation
$privilegesarray
Calls 8
public function render(Output $out): void

Writes the kind and the names.

Parameters

$outOutput
Calls 1

Test cases 7§

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

Dedicated tests 5
Other tests reaching this symbol 2

Relations§

Instantiated in 1