feat: support postgres alter schema (#2038)
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run

This commit is contained in:
Chen Chongchen 2025-09-19 16:37:27 +08:00 committed by GitHub
parent ea7f9026f7
commit 0b723147b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 87 additions and 1 deletions

View file

@ -6576,3 +6576,66 @@ fn parse_create_server() {
assert_eq!(stmt, expected);
}
}
#[test]
fn parse_alter_schema() {
match pg_and_generic().verified_stmt("ALTER SCHEMA foo RENAME TO bar") {
Statement::AlterSchema(AlterSchema { operations, .. }) => {
assert_eq!(
operations,
vec![AlterSchemaOperation::Rename {
name: ObjectName::from(vec!["bar".into()])
}]
);
}
_ => unreachable!(),
}
match pg_and_generic().verified_stmt("ALTER SCHEMA foo OWNER TO bar") {
Statement::AlterSchema(AlterSchema { operations, .. }) => {
assert_eq!(
operations,
vec![AlterSchemaOperation::OwnerTo {
owner: Owner::Ident("bar".into())
}]
);
}
_ => unreachable!(),
}
match pg_and_generic().verified_stmt("ALTER SCHEMA foo OWNER TO CURRENT_ROLE") {
Statement::AlterSchema(AlterSchema { operations, .. }) => {
assert_eq!(
operations,
vec![AlterSchemaOperation::OwnerTo {
owner: Owner::CurrentRole
}]
);
}
_ => unreachable!(),
}
match pg_and_generic().verified_stmt("ALTER SCHEMA foo OWNER TO CURRENT_USER") {
Statement::AlterSchema(AlterSchema { operations, .. }) => {
assert_eq!(
operations,
vec![AlterSchemaOperation::OwnerTo {
owner: Owner::CurrentUser
}]
);
}
_ => unreachable!(),
}
match pg_and_generic().verified_stmt("ALTER SCHEMA foo OWNER TO SESSION_USER") {
Statement::AlterSchema(AlterSchema { operations, .. }) => {
assert_eq!(
operations,
vec![AlterSchemaOperation::OwnerTo {
owner: Owner::SessionUser
}]
);
}
_ => unreachable!(),
}
}