@@ -607,41 +607,74 @@ void parseDqlStatementWithLogQuerySetLogQueryFlag() throws Exception {
607
607
}
608
608
609
609
@ Test
610
- void parseDmlStatementWithDryRunSetDryRunFalse () throws Exception {
610
+ void parseUpdateStatementWithoutDryRunSetsDryRunOptionsToFalse () throws Exception {
611
611
validate (List .of ("update A set A2 = 52 where A1 > 2" ),
612
612
PreparedParams .empty (),
613
- "update \" A\" set \" A2\" = ? where \" A1\" > ? " , // note: this is irrelevant as the query will be recompiled anyway.
613
+ "update \" A\" set \" A2\" = ? where \" A1\" > ? " ,
614
614
List .of (Map .of (constantId (5 ), 52 , constantId (9 ), 2 )),
615
615
null ,
616
616
-1 ,
617
- EnumSet .of (AstNormalizer .Result .QueryCachingFlags .IS_DML_STATEMENT ),
617
+ EnumSet .of (AstNormalizer .Result .QueryCachingFlags .IS_UPDATE_STATEMENT ),
618
618
Map .of (Options .Name .DRY_RUN , false ));
619
619
}
620
620
621
621
@ Test
622
- void parseDmlStatementWithDryRunSetDryRunTrue () throws Exception {
622
+ void parseUpdateStatementWithDryRunOptionSetsDryRunToTrue () throws Exception {
623
623
validate (List .of ("update A set A2 = 52 where A1 > 2 OPTIONS(DRY RUN)" ),
624
624
PreparedParams .empty (),
625
- "update \" A\" set \" A2\" = ? where \" A1\" > ? " , // note: this is irrelevant as the query will be recompiled anyway.
625
+ "update \" A\" set \" A2\" = ? where \" A1\" > ? " ,
626
626
List .of (Map .of (constantId (5 ), 52 , constantId (9 ), 2 )),
627
627
null ,
628
628
-1 ,
629
- EnumSet .of (AstNormalizer .Result .QueryCachingFlags .IS_DML_STATEMENT ),
629
+ EnumSet .of (AstNormalizer .Result .QueryCachingFlags .IS_UPDATE_STATEMENT ),
630
630
Map .of (Options .Name .DRY_RUN , true ));
631
631
}
632
632
633
633
@ Test
634
- void parseDmlStatementWithMultipleQueryOptions () throws Exception {
634
+ void parseUpdateStatementWithMultipleQueryOptions () throws Exception {
635
635
validate (List .of ("update A set A2 = 52 where A1 > 2 OPTIONS(DRY RUN, nocache, log query)" ),
636
636
PreparedParams .empty (),
637
- "update \" A\" set \" A2\" = ? where \" A1\" > ? " , // note: this is irrelevant as the query will be recompiled anyway.
637
+ "update \" A\" set \" A2\" = ? where \" A1\" > ? " ,
638
638
List .of (Map .of (constantId (5 ), 52 , constantId (9 ), 2 )),
639
639
null ,
640
640
-1 ,
641
- EnumSet .of (AstNormalizer .Result .QueryCachingFlags .IS_DML_STATEMENT , AstNormalizer .Result .QueryCachingFlags .WITH_NO_CACHE_OPTION ),
641
+ EnumSet .of (AstNormalizer .Result .QueryCachingFlags .IS_UPDATE_STATEMENT , AstNormalizer .Result .QueryCachingFlags .WITH_NO_CACHE_OPTION ),
642
642
Map .of (Options .Name .DRY_RUN , true , Options .Name .LOG_QUERY , true ));
643
643
}
644
644
645
+ @ Test
646
+ void parseUpdateStatementSetsQueryFlagCorrectly () throws Exception {
647
+ validate (List .of ("update A set A2 = 52 where A1 > 2" ),
648
+ PreparedParams .empty (),
649
+ "update \" A\" set \" A2\" = ? where \" A1\" > ? " ,
650
+ List .of (Map .of (constantId (5 ), 52 , constantId (9 ), 2 )),
651
+ null ,
652
+ -1 ,
653
+ EnumSet .of (AstNormalizer .Result .QueryCachingFlags .IS_UPDATE_STATEMENT ));
654
+ }
655
+
656
+ @ Test
657
+ void parseInsertStatementSetsQueryFlagCorrectly () throws Exception {
658
+ validate (List .of ("insert into A values (42, 'foo')" ),
659
+ PreparedParams .empty (),
660
+ "insert into \" A\" values ( ? , ? ) " ,
661
+ List .of (Map .of (constantId (5 ), 42 , constantId (7 ), "foo" )),
662
+ null ,
663
+ -1 ,
664
+ EnumSet .of (AstNormalizer .Result .QueryCachingFlags .IS_INSERT_STATEMENT ));
665
+ }
666
+
667
+ @ Test
668
+ void parseDeleteStatementSetsQueryFlagCorrectly () throws Exception {
669
+ validate (List .of ("delete from A where x = 42" ),
670
+ PreparedParams .empty (),
671
+ "delete from \" A\" where \" X\" = ? " ,
672
+ List .of (Map .of (constantId (6 ), 42 )),
673
+ null ,
674
+ -1 ,
675
+ EnumSet .of (AstNormalizer .Result .QueryCachingFlags .IS_DELETE_STATEMENT ));
676
+ }
677
+
645
678
@ Test
646
679
void queryHashWorksWithPreparedParameters () throws Exception {
647
680
validate (List .of (
0 commit comments