You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the library only supports `CREATE ROLE` and `ALTER ROLE` for
PostgreSQL. `CREATE USER` and `ALTER USER` fail to parse with errors
like `"Expected: an object type after CREATE, found: USER"`
But in PostgreSQL reference:
- `CREATE USER` is equivalent to `CREATE ROLE`, except that `LOGIN` is assumed by default
- `ALTER USER` is an alias to `ALTER ROLE`
- Both should support the same options as their ROLE counterparts
This commit extends the existing `CreateRole` and `AlterRole`
structures to distinct which keyword has been used: `USER` or
`ROLE`. It allows these expressions to be parsed and displayed back.
// PostgreSQL has different CREATE USER semantics (CREATE ROLE with LOGIN=true),
16604
+
// so we exclude it from this test which is for Snowflake-style CREATE USER
16605
+
let dialects = all_dialects_except(|d| d.is::<PostgreSqlDialect>());
16606
+
16607
+
let create = dialects.verified_stmt("CREATE USER u1");
16604
16608
match create {
16605
16609
Statement::CreateUser(stmt) => {
16606
16610
assert_eq!(stmt.name, Ident::new("u1"));
16607
16611
}
16608
16612
_ => unreachable!(),
16609
16613
}
16610
-
verified_stmt("CREATE OR REPLACE USER u1");
16611
-
verified_stmt("CREATE OR REPLACE USER IF NOT EXISTS u1");
16612
-
verified_stmt("CREATE OR REPLACE USER IF NOT EXISTS u1 PASSWORD='secret'");
16613
-
verified_stmt(
16614
+
dialects.verified_stmt("CREATE OR REPLACE USER u1");
16615
+
dialects.verified_stmt("CREATE OR REPLACE USER IF NOT EXISTS u1");
16616
+
dialects.verified_stmt("CREATE OR REPLACE USER IF NOT EXISTS u1 PASSWORD='secret'");
16617
+
dialects.verified_stmt(
16614
16618
"CREATE OR REPLACE USER IF NOT EXISTS u1 PASSWORD='secret' MUST_CHANGE_PASSWORD=TRUE",
16615
16619
);
16616
-
verified_stmt("CREATE OR REPLACE USER IF NOT EXISTS u1 PASSWORD='secret' MUST_CHANGE_PASSWORD=TRUE TYPE=SERVICE TAG (t1='v1')");
16617
-
let create = verified_stmt("CREATE OR REPLACE USER IF NOT EXISTS u1 PASSWORD='secret' MUST_CHANGE_PASSWORD=TRUE TYPE=SERVICE WITH TAG (t1='v1', t2='v2')");
16620
+
dialects.verified_stmt("CREATE OR REPLACE USER IF NOT EXISTS u1 PASSWORD='secret' MUST_CHANGE_PASSWORD=TRUE TYPE=SERVICE TAG (t1='v1')");
16621
+
let create = dialects.verified_stmt("CREATE OR REPLACE USER IF NOT EXISTS u1 PASSWORD='secret' MUST_CHANGE_PASSWORD=TRUE TYPE=SERVICE WITH TAG (t1='v1', t2='v2')");
0 commit comments