classPrivilege
final class Privilege
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.One privilege of a GRANT or REVOKE, optionally limited to columns; in a role grant, the granted role.
Mirrors AccessPriv: a privilege name and a column list. The name is one of the keyword spellings or an identifier such as insert or usage; ALL with a column list is the privilege without a name. The grammar reads the roles of GRANT role TO role with the same production, so there the name is the role name, and a keyword spelling names the role of that word. Source: https://www.postgresql.org/docs/17/sql-grant.html.
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('GRANT UPDATE (price) ON items TO joe');
[$operation->statement->privileges[0]->privilege(), $operation->statement->privileges[0]->columns[0]->value] // => ['update', 'price']new \SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\Privilege(\SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Privilege\PrivilegeKeyword::All) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public list<Name> $columnspublic PrivilegeKeyword|Name $nameMethods§
public function __construct(public PrivilegeKeyword|Name $name, list<Name> $columns = [])Parameters
$name | PrivilegeKeyword|Name | The keyword spelling or the identifier that names the privilege |
$columns | list<Name> | The columns the privilege is limited to; empty when no column list is written |
Calls 5
- static-call Check::listOf() line 46
- class-const Name::class() line 46
- static-call Check::input() line 47
- class-const PrivilegeKeyword::All() line 47
- class-const PrivilegeKeyword::AlterSystem() line 48
public function privilege(): ?stringAnswers the privilege name the server receives, or null for ALL.
Returns
?stringTest cases 3
public function render(Output $out): voidWrites the name and the column list, if any.
Parameters
$out | Output |
Calls 5
- method-call Output::name() line 65
- class-const NameUse::Column() line 65
- method-call Output::keyword() line 67
- function-call
explodeline 67 - method-call Output::symbol() line 70
Test cases 9§
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 4
Relations§
Instantiated in 7
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\PrivilegeRule::privileges() packages/sql-semantics-postgres/src/Lowering/Access/PrivilegeRule.php:51
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\PrivilegeRule::privileges() packages/sql-semantics-postgres/src/Lowering/Access/PrivilegeRule.php:52
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\PrivilegeRule::privilege() packages/sql-semantics-postgres/src/Lowering/Access/PrivilegeRule.php:83
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\PrivilegeRule::privilege() packages/sql-semantics-postgres/src/Lowering/Access/PrivilegeRule.php:84
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\PrivilegeRule::privilege() packages/sql-semantics-postgres/src/Lowering/Access/PrivilegeRule.php:85
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\PrivilegeRule::privilege() packages/sql-semantics-postgres/src/Lowering/Access/PrivilegeRule.php:86
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\PrivilegeRule::privilege() packages/sql-semantics-postgres/src/Lowering/Access/PrivilegeRule.php:87
Method calls 1
Constant reads 2
- class-const SqlSemantics\Platform\PostgreSql\Rules\Access\PrivilegeLists::privileges() packages/sql-semantics-postgres/src/Rules/Access/PrivilegeLists.php:39
- class-const SqlSemantics\Platform\PostgreSql\Rules\Access\PrivilegeLists::roles() packages/sql-semantics-postgres/src/Rules/Access/PrivilegeLists.php:58