99 InlineTables ,
1010 CacheDriverInterface ,
1111 TableStructure ,
12- DriverInterface ,
12+ DriverInterface , QueryKey ,
1313} from '@cubejs-backend/base-driver' ;
1414
1515import { QueryQueue } from './QueryQueue' ;
@@ -28,14 +28,12 @@ type QueryOptions = {
2828 incremental ?: boolean ;
2929} ;
3030
31- export type QueryTuple = [
31+ export type QueryWithParams = [
3232 sql : string ,
33- params : unknown [ ] ,
33+ params : string [ ] ,
3434 options ?: QueryOptions
3535] ;
3636
37- export type QueryWithParams = QueryTuple ;
38-
3937export type Query = {
4038 requestId ?: string ;
4139 dataSource : string ;
@@ -84,7 +82,7 @@ export type PreAggTableToTempTable = [
8482
8583export type PreAggTableToTempTableNames = [ string , { targetTableName : string ; } ] ;
8684
87- export type CacheKeyItem = string | string [ ] | QueryTuple | QueryTuple [ ] | undefined ;
85+ export type CacheKeyItem = string | string [ ] | QueryWithParams | QueryWithParams [ ] | undefined ;
8886
8987export type CacheKey =
9088 [ CacheKeyItem , CacheKeyItem ] |
@@ -382,7 +380,7 @@ export class QueryCache {
382380 public static replacePreAggregationTableNames (
383381 queryAndParams : string | QueryWithParams ,
384382 preAggregationsTablesToTempTables : PreAggTableToTempTableNames [ ] ,
385- ) : string | QueryTuple {
383+ ) : string | QueryWithParams {
386384 const [ keyQuery , params , queryOptions ] = Array . isArray ( queryAndParams )
387385 ? queryAndParams
388386 : [ queryAndParams , [ ] ] ;
@@ -404,7 +402,7 @@ export class QueryCache {
404402 * queries and with the `stream.Writable` instance for the persistent.
405403 */
406404 public async queryWithRetryAndRelease (
407- query : string | QueryTuple ,
405+ query : string | QueryWithParams ,
408406 values : string [ ] ,
409407 {
410408 cacheKey,
@@ -665,9 +663,9 @@ export class QueryCache {
665663 }
666664
667665 public startRenewCycle (
668- query : string | QueryTuple ,
666+ query : string | QueryWithParams ,
669667 values : string [ ] ,
670- cacheKeyQueries : ( string | QueryTuple ) [ ] ,
668+ cacheKeyQueries : ( string | QueryWithParams ) [ ] ,
671669 expireSecs : number ,
672670 cacheKey : CacheKey ,
673671 renewalThreshold : any ,
@@ -700,9 +698,9 @@ export class QueryCache {
700698 }
701699
702700 public renewQuery (
703- query : string | QueryTuple ,
701+ query : string | QueryWithParams ,
704702 values : string [ ] ,
705- cacheKeyQueries : ( string | QueryTuple ) [ ] ,
703+ cacheKeyQueries : ( string | QueryWithParams ) [ ] ,
706704 expireSecs : number ,
707705 cacheKey : CacheKey ,
708706 renewalThreshold : any ,
@@ -719,7 +717,7 @@ export class QueryCache {
719717 ) {
720718 options = options || { dataSource : 'default' } ;
721719 return Promise . all (
722- this . loadRefreshKeys ( < QueryTuple [ ] > cacheKeyQueries , expireSecs , options ) ,
720+ this . loadRefreshKeys ( < QueryWithParams [ ] > cacheKeyQueries , expireSecs , options ) ,
723721 )
724722 . catch ( e => {
725723 if ( e instanceof ContinueWaitError ) {
@@ -782,11 +780,11 @@ export class QueryCache {
782780 }
783781 ) {
784782 return cacheKeyQueries . map ( ( q ) => {
785- const [ query , values , queryOptions ] : QueryTuple = Array . isArray ( q ) ? q : [ q , [ ] , { } ] ;
783+ const [ query , values , queryOptions ] : QueryWithParams = Array . isArray ( q ) ? q : [ q , [ ] , { } ] ;
786784 return this . cacheQueryResult (
787785 query ,
788- < string [ ] > values ,
789- [ query , < string [ ] > values ] ,
786+ values ,
787+ [ query , values ] ,
790788 expireSecs ,
791789 {
792790 renewalThreshold : this . options . refreshKeyRenewalThreshold || queryOptions ?. renewalThreshold || 2 * 60 ,
@@ -808,7 +806,7 @@ export class QueryCache {
808806 ) => this . cacheDriver . withLock ( `lock:${ key } ` , callback , ttl , true ) ;
809807
810808 public async cacheQueryResult (
811- query : string | QueryTuple ,
809+ query : string | QueryWithParams ,
812810 values : string [ ] ,
813811 cacheKey : CacheKey ,
814812 expiration : number ,
@@ -990,7 +988,7 @@ export class QueryCache {
990988 return null ;
991989 }
992990
993- public queryRedisKey ( cacheKey ) : string {
991+ public queryRedisKey ( cacheKey : CacheKey ) : string {
994992 return this . getKey ( 'SQL_QUERY_RESULT' , getCacheHash ( cacheKey ) as any ) ;
995993 }
996994
0 commit comments