Skip to content

Commit

Permalink
Move tests to a common module and add a handler for '+'
Browse files Browse the repository at this point in the history
  • Loading branch information
Agaev Huseyn committed Sep 10, 2024
1 parent a0873ca commit 216d721
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7274,7 +7274,7 @@ impl<'a> Parser<'a> {
let placeholder = tok.to_string() + &ident.value;
Ok(Value::Placeholder(placeholder))
}
tok @ Token::Minus => {
tok @ Token::Minus | tok @ Token::Plus => {
let next_token = self.next_token();
match next_token.token {
Token::Number(n, l) => Ok(Value::Number(
Expand Down
23 changes: 23 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2819,6 +2819,29 @@ fn parse_window_function_null_treatment_arg() {
);
}

#[test]
fn parse_signed_value() {
let sql1 = "CREATE SEQUENCE name1
AS BIGINT
INCREMENT -15
MINVALUE - 2000 MAXVALUE -50
START WITH - 60";
one_statement_parses_to(
sql1,
"CREATE SEQUENCE name1 AS BIGINT INCREMENT -15 MINVALUE -2000 MAXVALUE -50 START WITH -60",
);

let sql2 = "CREATE SEQUENCE name2
AS BIGINT
INCREMENT +10
MINVALUE + 30 MAXVALUE +5000
START WITH + 45";
one_statement_parses_to(
sql2,
"CREATE SEQUENCE name2 AS BIGINT INCREMENT +10 MINVALUE +30 MAXVALUE +5000 START WITH +45",
);
}

#[test]
fn parse_create_table() {
let sql = "CREATE TABLE uk_cities (\
Expand Down
10 changes: 0 additions & 10 deletions tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,6 @@ fn parse_create_sequence() {
"CREATE TEMPORARY SEQUENCE IF NOT EXISTS name3 INCREMENT 1 NO MINVALUE MAXVALUE 20 OWNED BY NONE",
);

let sql7 = "CREATE SEQUENCE name4
AS BIGINT
INCREMENT -10
MINVALUE - 2000 MAXVALUE -5
START WITH - 20";
pg().one_statement_parses_to(
sql7,
"CREATE SEQUENCE name4 AS BIGINT INCREMENT -10 MINVALUE -2000 MAXVALUE -5 START WITH -20",
);

assert!(matches!(
pg().parse_sql_statements("CREATE SEQUENCE foo INCREMENT 1 NO MINVALUE NO"),
Err(ParserError::ParserError(_))
Expand Down

0 comments on commit 216d721

Please sign in to comment.