final class GrantRole
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

A request to make roles members of other roles.

Rule: PG-GRANT-ROLE-001. Mirrors GrantRoleStmt with is_grant: the granted roles, the member roles, the membership options of WITH and GRANTED BY. The grammar reads the granted roles as a privilege list, so a granted role may carry a column list or be spelled with a privilege keyword; a column list is reported, as are an option name the server does not recognize and PUBLIC as a granted role, member or grantor (PG-MEMBERSHIP-CHECK-001). Source: https://www.postgresql.org/docs/17/sql-grant.html#SQL-GRANT-DESCRIPTION-ROLES. Status: Implemented.

Reading a membership grantdoctest
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('GRANT staff TO joe WITH ADMIN OPTION GRANTED BY boss');
    [$operation->statement->roles[0]->privilege(), $operation->statement->options[0]->setting->value, $operation->statement->grantor?->name?->value] // => ['staff', 'OPTION', 'boss']

Properties§

public non-empty-list<Privilege> $roles
public non-empty-list<RoleSpec> $members
public list<MembershipOption> $options
public RoleSpec|null $grantor = null

Methods§

public function __construct(
    list<Privilege> $roles,
    list<RoleSpec> $members,
    list<MembershipOption> $options = [],
    public RoleSpec|null $grantor = null,
)

Parameters

$roleslist<Privilege>The granted roles in the order written, at least one
$memberslist<RoleSpec>The roles that become members, at least one
$optionslist<MembershipOption>The options of WITH in the order written
$grantorRoleSpec|nullThe role of GRANTED BY, when written
Calls 5
public function deriveStatement(Derivation $derivation): void

Reports the problems of the roles and of the options.

Parameters

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

Writes the request.

Parameters

$outOutput
Calls 1

Test cases 4§

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

Dedicated tests 3
Other tests reaching this symbol 1

Relations§

Instantiated in 2