classCreateRole
final class CreateRole
implements Statement
uses Snapshot
@visibility public.A request to create a role, written as CREATE ROLE, CREATE USER or CREATE GROUP.
Rule: PG-ROLE-CREATE-001. Mirrors CreateRoleStmt: the statement word (RoleStmtType; CREATE USER makes LOGIN the default), the role name and the options in the order written. The optional WITH before the options is not kept. Reported: a name starting with pg_, an option filled twice, an unrecognized option word, UNENCRYPTED PASSWORD, a connection limit below -1 and PUBLIC in a role list (PG-ROLE-CHECK-001). A role is not a relation declaration: the statement provides none. Source: https://www.postgresql.org/docs/17/sql-createrole.html, https://www.postgresql.org/docs/17/sql-createuser.html, https://www.postgresql.org/docs/17/sql-creategroup.html. Status: Implemented.
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("CREATE USER joe WITH LOGIN ENCRYPTED PASSWORD 'secret'");
[$operation->statement->name->value, $operation->statement->options[0]->option(), $operation->toString()] // => ['joe', 'canlogin', "CREATE USER joe login PASSWORD 'secret'"]Properties§
public list<RoleOption> $optionspublic RoleWord $wordpublic Name $nameMethods§
public function __construct(
public RoleWord $word,
public Name $name,
list<RoleOption> $options = [],
)Parameters
$word | RoleWord | The statement word: ROLE, USER or GROUP |
$name | Name | The role name |
$options | list<RoleOption> | The options in the order written |
Calls 2
- static-call Check::listOf() line 51
- class-const RoleOption::class() line 51
public function deriveStatement(Derivation $derivation): voidReports the problems of the name and of the options.
Parameters
$derivation | Derivation |
Calls 3
- new RoleChecks line 59
- method-call RoleChecks::reserved() line 60
- method-call RoleChecks::options() line 61
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 69
- class-const NameUse::Column() line 69
- method-call Output::node() line 71
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Relations§
Instantiated in 3
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\RoleRule::statement() packages/sql-semantics-postgres/src/Lowering/Access/RoleRule.php:95
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\RoleRule::statement() packages/sql-semantics-postgres/src/Lowering/Access/RoleRule.php:96
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\RoleRule::statement() packages/sql-semantics-postgres/src/Lowering/Access/RoleRule.php:97