@@ -367,30 +367,37 @@ export class LocalExecutor implements QueryExecutor {
367367 private queryCacheKey ( query : QueryDescriptor ) : string {
368368 let h = 0x811c9dc5 ;
369369 const feed = ( s : string ) => { for ( let i = 0 ; i < s . length ; i ++ ) { h ^= s . charCodeAt ( i ) ; h = Math . imul ( h , 0x01000193 ) ; } } ;
370- feed ( query . table ) ;
370+ feed ( query . table ) ; feed ( "\0" ) ;
371+ if ( query . version !== undefined ) { feed ( `v${ query . version } ` ) ; feed ( "\0" ) ; }
371372 for ( const f of [ ...query . filters ] . sort ( ( a , b ) => a . column . localeCompare ( b . column ) || a . op . localeCompare ( b . op ) ) ) {
372- feed ( f . column ) ; feed ( f . op ) ; feed ( String ( f . value ) ) ;
373+ feed ( f . column ) ; feed ( "\0" ) ; feed ( f . op ) ; feed ( "\0" ) ; feed ( String ( f . value ) ) ; feed ( "\0" ) ;
373374 }
374- for ( const p of [ ...query . projections ] . sort ( ) ) feed ( p ) ;
375- if ( query . sortColumn ) { feed ( query . sortColumn ) ; feed ( query . sortDirection ?? "asc" ) ; }
376- if ( query . limit !== undefined ) feed ( String ( query . limit ) ) ;
377- if ( query . offset !== undefined ) feed ( String ( query . offset ) ) ;
378375 if ( query . filterGroups ) {
379376 for ( const group of query . filterGroups ) {
380377 feed ( "|" ) ;
381378 for ( const f of [ ...group ] . sort ( ( a , b ) => a . column . localeCompare ( b . column ) || a . op . localeCompare ( b . op ) ) ) {
382- feed ( f . column ) ; feed ( f . op ) ; feed ( String ( f . value ) ) ;
379+ feed ( f . column ) ; feed ( "\0" ) ; feed ( f . op ) ; feed ( "\0" ) ; feed ( String ( f . value ) ) ; feed ( "\0" ) ;
383380 }
384381 }
385382 }
386- if ( query . aggregates ) for ( const a of query . aggregates ) { feed ( a . fn ) ; feed ( a . column ) ; if ( a . alias ) feed ( a . alias ) ; }
387- if ( query . groupBy ) for ( const g of query . groupBy ) feed ( g ) ;
388- if ( query . distinct ) feed ( "distinct" ) ;
389- if ( query . version !== undefined ) feed ( `v${ query . version } ` ) ;
390- if ( query . windows ) for ( const w of query . windows ) { feed ( w . fn ) ; feed ( w . alias ) ; feed ( w . column ?? "" ) ; }
391- if ( query . computedColumns ) for ( const cc of query . computedColumns ) feed ( cc . name ) ;
392- if ( query . setOperation ) { feed ( query . setOperation . type ) ; feed ( query . setOperation . table ) ; }
393- if ( query . subqueryIn ) { feed ( query . subqueryIn . column ) ; feed ( query . subqueryIn . table ) ; }
383+ for ( const p of [ ...query . projections ] . sort ( ) ) { feed ( p ) ; feed ( "\0" ) ; }
384+ if ( query . sortColumn ) { feed ( query . sortColumn ) ; feed ( "\0" ) ; feed ( query . sortDirection ?? "asc" ) ; feed ( "\0" ) ; }
385+ if ( query . limit !== undefined ) { feed ( String ( query . limit ) ) ; feed ( "\0" ) ; }
386+ if ( query . offset !== undefined ) { feed ( String ( query . offset ) ) ; feed ( "\0" ) ; }
387+ if ( query . aggregates ) for ( const a of query . aggregates ) { feed ( a . fn ) ; feed ( "\0" ) ; feed ( a . column ) ; feed ( "\0" ) ; if ( a . alias ) feed ( a . alias ) ; feed ( "\0" ) ; }
388+ if ( query . groupBy ) for ( const g of query . groupBy ) { feed ( g ) ; feed ( "\0" ) ; }
389+ if ( query . distinct ) for ( const d of query . distinct ) { feed ( d ) ; feed ( "\0" ) ; }
390+ if ( query . windows ) for ( const w of query . windows ) {
391+ feed ( w . fn ) ; feed ( "\0" ) ; feed ( w . alias ) ; feed ( "\0" ) ; feed ( w . column ?? "" ) ; feed ( "\0" ) ;
392+ if ( w . partitionBy ) for ( const p of w . partitionBy ) { feed ( p ) ; feed ( "\0" ) ; }
393+ if ( w . orderBy ) for ( const o of w . orderBy ) { feed ( o . column ) ; feed ( o . direction ) ; feed ( "\0" ) ; }
394+ if ( w . frame ) { feed ( w . frame . type ) ; feed ( String ( w . frame . start ) ) ; feed ( String ( w . frame . end ) ) ; feed ( "\0" ) ; }
395+ if ( w . args ?. offset !== undefined ) { feed ( String ( w . args . offset ) ) ; feed ( "\0" ) ; }
396+ }
397+ if ( query . computedColumns ) for ( const cc of query . computedColumns ) { feed ( cc . alias ) ; feed ( "\0" ) ; }
398+ if ( query . setOperation ) { feed ( query . setOperation . mode ) ; feed ( "\0" ) ; feed ( this . queryCacheKey ( query . setOperation . right ) ) ; feed ( "\0" ) ; }
399+ if ( query . subqueryIn ) for ( const sq of query . subqueryIn ) { feed ( sq . column ) ; feed ( "\0" ) ; for ( const v of sq . valueSet ) { feed ( v ) ; feed ( "\0" ) ; } }
400+ if ( query . join ) { feed ( query . join . type ?? "inner" ) ; feed ( "\0" ) ; feed ( query . join . leftKey ) ; feed ( "\0" ) ; feed ( query . join . rightKey ) ; feed ( "\0" ) ; feed ( this . queryCacheKey ( query . join . right ) ) ; feed ( "\0" ) ; }
394401 return `qr:${ query . table } :${ ( h >>> 0 ) . toString ( 36 ) } ` ;
395402 }
396403
0 commit comments