@@ -498,92 +498,89 @@ mod update_statement_tests {
498
498
}
499
499
}
500
500
501
- // #[cfg(test)]
502
- // mod update_from_table_tests {
503
- // use super::test_utils::update_from;
504
- // use crate::parser::test_utils::*;
505
- // use crate::{FromClause, Identifier, IndexedType, QualifiedTableName, Statement};
506
-
507
- // #[test]
508
- // fn test_update_from_table() {
509
- // let expected_statement = update_from(FromClause::Table(QualifiedTableName::from(
510
- // Identifier::Single("table_1".to_string()),
511
- // )));
501
+ #[ cfg( test) ]
502
+ mod update_from_table_tests {
503
+ use super :: test_utils:: update_statement2;
504
+ use crate :: parser:: test_utils:: * ;
505
+ use crate :: { FromClause , Identifier , IndexedType , QualifiedTableName , Statement } ;
512
506
513
- // run_sunny_day_test(
514
- // "UPDATE table1 SET column1 = 1 FROM table_1",
515
- // Statement::Update(expected_statement),
516
- // );
517
- // }
507
+ #[ test]
508
+ fn update_from_table ( ) {
509
+ let mut expected_statement = update_statement2 ( ) ;
510
+ expected_statement. from_clause = Some ( FromClause :: Table ( QualifiedTableName :: from (
511
+ Identifier :: Single ( "table_1" . to_string ( ) ) ,
512
+ ) ) ) ;
518
513
519
- // #[test]
520
- // fn test_update_from_table_with_schema() {
521
- // let expected_statement = update_from(FromClause::Table(QualifiedTableName::from(
522
- // Identifier::Compound(vec!["schema_1".to_string(), "table_1".to_string()]),
523
- // )));
514
+ run_sunny_day_test (
515
+ "UPDATE table_name1 SET col1 = 1 FROM table_1" ,
516
+ Statement :: Update ( expected_statement ) ,
517
+ ) ;
518
+ }
524
519
525
- // run_sunny_day_test(
526
- // "UPDATE table1 SET column1 = 1 FROM schema_1.table_1",
527
- // Statement::Update(expected_statement),
528
- // );
529
- // }
520
+ #[ test]
521
+ fn update_from_table_with_schema ( ) {
522
+ let mut expected_statement = update_statement2 ( ) ;
523
+ expected_statement. from_clause = Some ( FromClause :: Table ( QualifiedTableName :: from (
524
+ Identifier :: Compound ( vec ! [ "schema_1" . to_string( ) , "table_1" . to_string( ) ] ) ,
525
+ ) ) ) ;
530
526
531
- // #[test]
532
- // fn test_update_from_table_with_alias() {
533
- // let expected_statement = update_from(FromClause::Table(QualifiedTableName {
534
- // table_id: Identifier::Compound(vec!["schema_1".to_string(), "table_1".to_string()]),
535
- // alias: Some("alias".to_string()),
536
- // indexed_type: None,
537
- // }));
527
+ run_sunny_day_test (
528
+ "UPDATE table_name1 SET col1 = 1 FROM schema_1.table_1" ,
529
+ Statement :: Update ( expected_statement) ,
530
+ ) ;
531
+ }
538
532
539
- // run_sunny_day_test(
540
- // "UPDATE table1 SET column1 = 1 FROM schema_1.table_1 AS alias",
541
- // Statement::Update(expected_statement),
542
- // );
543
- // }
533
+ #[ test]
534
+ fn update_from_table_with_alias ( ) {
535
+ let mut expected_statement = update_statement2 ( ) ;
536
+ expected_statement. from_clause = Some ( FromClause :: Table ( QualifiedTableName {
537
+ table_id : Identifier :: Compound ( vec ! [ "schema_1" . to_string( ) , "table_1" . to_string( ) ] ) ,
538
+ alias : Some ( "alias" . to_string ( ) ) ,
539
+ indexed_type : None ,
540
+ } ) ) ;
544
541
545
- // #[test]
546
- // fn test_update_from_table_with_alias_without_as_keyword() {
547
- // let expected_statement = update_from(FromClause::Table(QualifiedTableName {
548
- // table_id: Identifier::Single("table_1".to_string()),
549
- // alias: Some("alias".to_string()),
550
- // indexed_type: None,
551
- // }));
542
+ run_sunny_day_test (
543
+ "UPDATE table_name1 SET col1 = 1 FROM schema_1.table_1 AS alias" ,
544
+ Statement :: Update ( expected_statement. clone ( ) ) ,
545
+ ) ;
552
546
553
- // run_sunny_day_test(
554
- // "UPDATE table1 SET column1 = 1 FROM table_1 alias",
555
- // Statement::Update(expected_statement),
556
- // );
557
- // }
547
+ // without the as keyword
548
+ run_sunny_day_test (
549
+ "UPDATE table_name1 SET col1 = 1 FROM schema_1.table_1 alias" ,
550
+ Statement :: Update ( expected_statement) ,
551
+ ) ;
552
+ }
558
553
559
- // #[test]
560
- // fn test_update_from_table_with_alias_indexed() {
561
- // let expected_statement = update_from(FromClause::Table(QualifiedTableName {
562
- // table_id: Identifier::Single("table_1".to_string()),
563
- // alias: Some("alias".to_string()),
564
- // indexed_type: Some(IndexedType::Indexed("index_1".to_string())),
565
- // }));
554
+ #[ test]
555
+ fn update_from_table_indexed ( ) {
556
+ let mut expected_statement = update_statement2 ( ) ;
557
+ expected_statement. from_clause = Some ( FromClause :: Table ( QualifiedTableName {
558
+ table_id : Identifier :: Single ( "table_1" . to_string ( ) ) ,
559
+ alias : None ,
560
+ indexed_type : Some ( IndexedType :: Indexed ( "index_1" . to_string ( ) ) ) ,
561
+ } ) ) ;
566
562
567
- // run_sunny_day_test(
568
- // "UPDATE table1 SET column1 = 1 FROM table_1 alias INDEXED BY index_1",
569
- // Statement::Update(expected_statement),
570
- // );
571
- // }
563
+ run_sunny_day_test (
564
+ "UPDATE table_name1 SET col1 = 1 FROM table_1 INDEXED BY index_1" ,
565
+ Statement :: Update ( expected_statement) ,
566
+ ) ;
567
+ }
572
568
573
- // #[test]
574
- // fn test_update_from_table_not_indexed() {
575
- // let expected_statement = update_from(FromClause::Table(QualifiedTableName {
576
- // table_id: Identifier::Single("table_1".to_string()),
577
- // alias: None,
578
- // indexed_type: Some(IndexedType::NotIndexed),
579
- // }));
569
+ #[ test]
570
+ fn update_from_table_not_indexed ( ) {
571
+ let mut expected_statement = update_statement2 ( ) ;
572
+ expected_statement. from_clause = Some ( FromClause :: Table ( QualifiedTableName {
573
+ table_id : Identifier :: Single ( "table_1" . to_string ( ) ) ,
574
+ alias : None ,
575
+ indexed_type : Some ( IndexedType :: NotIndexed ) ,
576
+ } ) ) ;
580
577
581
- // run_sunny_day_test(
582
- // "UPDATE table1 SET column1 = 1 FROM table_1 NOT INDEXED",
583
- // Statement::Update(expected_statement),
584
- // );
585
- // }
586
- // }
578
+ run_sunny_day_test (
579
+ "UPDATE table_name1 SET col1 = 1 FROM table_1 NOT INDEXED" ,
580
+ Statement :: Update ( expected_statement) ,
581
+ ) ;
582
+ }
583
+ }
587
584
588
585
// #[cfg(test)]
589
586
// mod update_from_subquery_tests {
0 commit comments