|
23 | 23 | mod test_utils;
|
24 | 24 |
|
25 | 25 | use helpers::attached_token::AttachedToken;
|
26 |
| -use sqlparser::tokenizer::{Location, Span}; |
| 26 | +use sqlparser::keywords::Keyword; |
| 27 | +use sqlparser::tokenizer::{Location, Span, Token, TokenWithSpan, Word}; |
27 | 28 | use test_utils::*;
|
28 | 29 |
|
29 | 30 | use sqlparser::ast::DataType::{Int, Text, Varbinary};
|
@@ -1419,7 +1420,40 @@ fn test_mssql_cursor() {
|
1419 | 1420 | #[test]
|
1420 | 1421 | fn test_mssql_while_statement() {
|
1421 | 1422 | let while_single_statement = "WHILE 1 = 0 PRINT 'Hello World';";
|
1422 |
| - let _ = ms().verified_stmt(while_single_statement); |
| 1423 | + let stmt = ms().verified_stmt(while_single_statement); |
| 1424 | + assert_eq!( |
| 1425 | + stmt, |
| 1426 | + Statement::While(sqlparser::ast::WhileStatement { |
| 1427 | + while_block: ConditionalStatementBlock { |
| 1428 | + start_token: AttachedToken(TokenWithSpan { |
| 1429 | + token: Token::Word(Word { |
| 1430 | + value: "WHILE".to_string(), |
| 1431 | + quote_style: None, |
| 1432 | + keyword: Keyword::WHILE |
| 1433 | + }), |
| 1434 | + span: Span::empty() |
| 1435 | + }), |
| 1436 | + condition: Some(Expr::BinaryOp { |
| 1437 | + left: Box::new(Expr::Value( |
| 1438 | + (Value::Number("1".to_string(), false)).with_empty_span() |
| 1439 | + )), |
| 1440 | + op: BinaryOperator::Eq, |
| 1441 | + right: Box::new(Expr::Value( |
| 1442 | + (Value::Number("0".to_string(), false)).with_empty_span() |
| 1443 | + )), |
| 1444 | + }), |
| 1445 | + then_token: None, |
| 1446 | + conditional_statements: ConditionalStatements::Sequence { |
| 1447 | + statements: vec![Statement::Print(PrintStatement { |
| 1448 | + message: Box::new(Expr::Value( |
| 1449 | + (Value::SingleQuotedString("Hello World".to_string())) |
| 1450 | + .with_empty_span() |
| 1451 | + )), |
| 1452 | + }),], |
| 1453 | + } |
| 1454 | + } |
| 1455 | + }) |
| 1456 | + ); |
1423 | 1457 |
|
1424 | 1458 | let while_begin_end = "\
|
1425 | 1459 | WHILE @@FETCH_STATUS = 0 \
|
|
0 commit comments