mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-08 01:15:00 +00:00
Replacing the two booleans from 'SET ROLE' to a single enum. (#664)
This way, we don't rely on the parser to have valid structures for that statement, as the structure itself is valid.
This commit is contained in:
parent
a9939b0a4f
commit
777672625f
3 changed files with 66 additions and 39 deletions
|
@ -902,41 +902,44 @@ fn parse_set() {
|
|||
|
||||
#[test]
|
||||
fn parse_set_role() {
|
||||
let stmt = pg_and_generic().verified_stmt("SET SESSION ROLE NONE");
|
||||
let query = "SET SESSION ROLE NONE";
|
||||
let stmt = pg_and_generic().verified_stmt(query);
|
||||
assert_eq!(
|
||||
stmt,
|
||||
Statement::SetRole {
|
||||
local: false,
|
||||
session: true,
|
||||
context_modifier: ContextModifier::Session,
|
||||
role_name: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(query, stmt.to_string());
|
||||
|
||||
let stmt = pg_and_generic().verified_stmt("SET LOCAL ROLE \"rolename\"");
|
||||
let query = "SET LOCAL ROLE \"rolename\"";
|
||||
let stmt = pg_and_generic().verified_stmt(query);
|
||||
assert_eq!(
|
||||
stmt,
|
||||
Statement::SetRole {
|
||||
local: true,
|
||||
session: false,
|
||||
context_modifier: ContextModifier::Local,
|
||||
role_name: Some(Ident {
|
||||
value: "rolename".to_string(),
|
||||
quote_style: Some('\"'),
|
||||
}),
|
||||
}
|
||||
);
|
||||
assert_eq!(query, stmt.to_string());
|
||||
|
||||
let stmt = pg_and_generic().verified_stmt("SET ROLE 'rolename'");
|
||||
let query = "SET ROLE 'rolename'";
|
||||
let stmt = pg_and_generic().verified_stmt(query);
|
||||
assert_eq!(
|
||||
stmt,
|
||||
Statement::SetRole {
|
||||
local: false,
|
||||
session: false,
|
||||
context_modifier: ContextModifier::None,
|
||||
role_name: Some(Ident {
|
||||
value: "rolename".to_string(),
|
||||
quote_style: Some('\''),
|
||||
}),
|
||||
}
|
||||
);
|
||||
assert_eq!(query, stmt.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue