Skip to content

Commit 9df7e3d

Browse files
committed
Code review comments
1 parent 2322226 commit 9df7e3d

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/ast/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10108,12 +10108,12 @@ impl fmt::Display for CreateUser {
1010810108

1010910109
/// Modifies the properties of a user
1011010110
///
10111-
/// [Snowflake Syntax]:
10111+
/// [Snowflake Syntax:](https://docs.snowflake.com/en/sql-reference/sql/alter-user)
1011210112
/// ```sql
1011310113
/// ALTER USER [ IF EXISTS ] [ <name> ] [ OPTIONS ]
1011410114
/// ```
1011510115
///
10116-
/// [PostgreSQL Syntax]:(https://www.postgresql.org/docs/current/sql-alteruser.html)
10116+
/// [PostgreSQL Syntax:](https://www.postgresql.org/docs/current/sql-alteruser.html)
1011710117
/// ```sql
1011810118
/// ALTER USER <role_specification> [ WITH ] option [ ... ]
1011910119
/// ```
@@ -10338,10 +10338,10 @@ pub struct AlterUserPassword {
1033810338

1033910339
impl Display for AlterUserPassword {
1034010340
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10341-
write!(f, "PASSWORD")?;
1034210341
if self.encrypted {
10343-
write!(f, " ENCRYPTED")?;
10342+
write!(f, "ENCRYPTED ")?;
1034410343
}
10344+
write!(f, "PASSWORD")?;
1034510345
match &self.password {
1034610346
None => write!(f, " NULL")?,
1034710347
Some(password) => write!(f, " '{}'", value::escape_single_quote_string(password))?,

src/parser/alter.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,15 @@ impl Parser<'_> {
295295

296296
let encrypted = self.parse_keyword(Keyword::ENCRYPTED);
297297
let password = if self.parse_keyword(Keyword::PASSWORD) {
298-
if self.parse_keyword(Keyword::NULL) {
299-
Some(AlterUserPassword {
300-
encrypted,
301-
password: None,
302-
})
298+
let password = if self.parse_keyword(Keyword::NULL) {
299+
None
303300
} else {
304-
let password = self.parse_literal_string()?;
305-
Some(AlterUserPassword {
306-
encrypted,
307-
password: Some(password),
308-
})
309-
}
301+
Some(self.parse_literal_string()?)
302+
};
303+
Some(AlterUserPassword {
304+
encrypted,
305+
password,
306+
})
310307
} else {
311308
None
312309
};

tests/sqlparser_common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17952,6 +17952,9 @@ fn test_parse_alter_user() {
1795217952
verified_stmt("ALTER USER u1 SET DEFAULT_SECONDARY_ROLES=('ALL'), PASSWORD='secret', WORKLOAD_IDENTITY=(TYPE=AWS, ARN='arn:aws:iam::123456789:r1/')");
1795317953

1795417954
verified_stmt("ALTER USER u1 PASSWORD 'AAA'");
17955+
verified_stmt("ALTER USER u1 ENCRYPTED PASSWORD 'AAA'");
17956+
verified_stmt("ALTER USER u1 PASSWORD NULL");
17957+
1795517958
one_statement_parses_to(
1795617959
"ALTER USER u1 WITH PASSWORD 'AAA'",
1795717960
"ALTER USER u1 PASSWORD 'AAA'",

0 commit comments

Comments
 (0)