@@ -543,68 +543,90 @@ private module Spanner {
543
543
API:: Node database ( ) {
544
544
result =
545
545
spanner ( ) .getReturn ( ) .getMember ( "instance" ) .getReturn ( ) .getMember ( "database" ) .getReturn ( )
546
+ or
547
+ result = API:: Node:: ofType ( "@google-cloud/spanner" , "Database" )
546
548
}
547
549
548
550
/**
549
551
* Gets a node that refers to an instance of the `v1.SpannerClient` class.
550
552
*/
551
553
API:: Node v1SpannerClient ( ) {
552
554
result = spanner ( ) .getMember ( "v1" ) .getMember ( "SpannerClient" ) .getInstance ( )
555
+ or
556
+ result = API:: Node:: ofType ( "@google-cloud/spanner" , "v1.SpannerClient" )
553
557
}
554
558
555
559
/**
556
560
* Gets a node that refers to a transaction object.
557
561
*/
558
562
API:: Node transaction ( ) {
559
- result = database ( ) .getMember ( "runTransaction" ) .getParameter ( 0 ) .getParameter ( 1 )
563
+ result =
564
+ database ( )
565
+ .getMember ( [ "runTransaction" , "runTransactionAsync" ] )
566
+ .getParameter ( [ 0 , 1 ] )
567
+ .getParameter ( 1 )
568
+ or
569
+ result = API:: Node:: ofType ( "@google-cloud/spanner" , "Transaction" )
570
+ }
571
+
572
+ /** Gets an API node referring to a `BatchTransaction` object. */
573
+ API:: Node batchTransaction ( ) {
574
+ result = database ( ) .getMember ( "batchTransaction" ) .getReturn ( )
575
+ or
576
+ result = database ( ) .getMember ( "createBatchTransaction" ) .getReturn ( ) .getPromised ( )
577
+ or
578
+ result = API:: Node:: ofType ( "@google-cloud/spanner" , "BatchTransaction" )
560
579
}
561
580
562
581
/**
563
582
* A call to a Spanner method that executes a SQL query.
564
583
*/
565
- abstract class SqlExecution extends DatabaseAccess , DataFlow:: InvokeNode {
566
- /**
567
- * Gets the position of the query argument; default is zero, which can be overridden
568
- * by subclasses.
569
- */
570
- int getQueryArgumentPosition ( ) { result = 0 }
571
-
572
- override DataFlow:: Node getAQueryArgument ( ) {
573
- result = getArgument ( getQueryArgumentPosition ( ) ) or
574
- result = getOptionArgument ( getQueryArgumentPosition ( ) , "sql" )
575
- }
576
- }
584
+ abstract class SqlExecution extends DatabaseAccess , DataFlow:: InvokeNode { }
577
585
578
586
/**
579
- * A call to `Database.run`, `Database.runPartitionedUpdate` or `Database.runStream` .
587
+ * A SQL execution that takes the input directly in the first argument or in the `sql` option .
580
588
*/
581
- class DatabaseRunCall extends SqlExecution {
582
- DatabaseRunCall ( ) {
589
+ class SqlExecutionDirect extends SqlExecution {
590
+ SqlExecutionDirect ( ) {
583
591
this = database ( ) .getMember ( [ "run" , "runPartitionedUpdate" , "runStream" ] ) .getACall ( )
592
+ or
593
+ this = transaction ( ) .getMember ( [ "run" , "runStream" , "runUpdate" ] ) .getACall ( )
594
+ or
595
+ this = batchTransaction ( ) .getMember ( "createQueryPartitions" ) .getACall ( )
596
+ }
597
+
598
+ override DataFlow:: Node getAQueryArgument ( ) {
599
+ result = getArgument ( 0 )
600
+ or
601
+ result = getOptionArgument ( 0 , "sql" )
584
602
}
585
603
}
586
604
587
605
/**
588
- * A call to `Transaction.run`, `Transaction.runStream` or `Transaction.runUpdate` .
606
+ * A SQL execution that takes an array of SQL strings or { sql: string } objects .
589
607
*/
590
- class TransactionRunCall extends SqlExecution {
591
- TransactionRunCall ( ) {
592
- this = transaction ( ) .getMember ( [ "run" , "runStream" , "runUpdate" ] ) .getACall ( )
608
+ class SqlExecutionBatch extends SqlExecution , API:: CallNode {
609
+ SqlExecutionBatch ( ) { this = transaction ( ) .getMember ( "batchUpdate" ) .getACall ( ) }
610
+
611
+ override DataFlow:: Node getAQueryArgument ( ) {
612
+ // just use the whole array as the query argument, as arrays becomes tainted if one of the elements
613
+ // are tainted
614
+ result = getArgument ( 0 )
615
+ or
616
+ result = getParameter ( 0 ) .getUnknownMember ( ) .getMember ( "sql" ) .getARhs ( )
593
617
}
594
618
}
595
619
596
620
/**
597
- * A call to `v1.SpannerClient.executeSql` or `v1.SpannerClient.executeStreamingSql`.
621
+ * A SQL execution that only takes the input in the `sql` option, and do not accept query strings
622
+ * directly.
598
623
*/
599
- class ExecuteSqlCall extends SqlExecution {
600
- ExecuteSqlCall ( ) {
624
+ class SqlExecutionWithOption extends SqlExecution {
625
+ SqlExecutionWithOption ( ) {
601
626
this = v1SpannerClient ( ) .getMember ( [ "executeSql" , "executeStreamingSql" ] ) .getACall ( )
602
627
}
603
628
604
- override DataFlow:: Node getAQueryArgument ( ) {
605
- // `executeSql` and `executeStreamingSql` do not accept query strings directly
606
- result = getOptionArgument ( 0 , "sql" )
607
- }
629
+ override DataFlow:: Node getAQueryArgument ( ) { result = getOptionArgument ( 0 , "sql" ) }
608
630
}
609
631
610
632
/**
0 commit comments