File tree Expand file tree Collapse file tree 3 files changed +26
-19
lines changed
Expand file tree Collapse file tree 3 files changed +26
-19
lines changed Original file line number Diff line number Diff line change 1414
1515import {
1616 RefName ,
17+ sql ,
1718 SqlCase ,
1819 SqlColumn ,
1920 SqlColumnList ,
@@ -569,29 +570,27 @@ describe('SqlQuery', () => {
569570 } ) ;
570571 } ) ;
571572
572- describe ( '#getContext' , ( ) => {
573+ describe ( '#hasContext / # getContext' , ( ) => {
573574 it ( 'works with nothing' , ( ) => {
574- expect (
575- SqlQuery . parse (
576- sane `
577- SELECT *
578- FROM wikipedia
579- ` ,
580- ) . getContext ( ) ,
581- ) . toEqual ( { } ) ;
575+ const query = sql `
576+ SELECT *
577+ FROM wikipedia
578+ ` as SqlQuery ;
579+
580+ expect ( query . hasContext ( ) ) . toEqual ( false ) ;
581+ expect ( query . getContext ( ) ) . toEqual ( { } ) ;
582582 } ) ;
583583
584584 it ( 'works with something' , ( ) => {
585- expect (
586- SqlQuery . parse (
587- sane `
588- SET b = 2;
589- SET c = 'hello';
590- SELECT *
591- FROM wikipedia;
592- ` ,
593- ) . getContext ( ) ,
594- ) . toEqual ( {
585+ const query = sql `
586+ SET b = 2;
587+ SET c = 'hello';
588+ SELECT *
589+ FROM wikipedia;
590+ ` as SqlQuery ;
591+
592+ expect ( query . hasContext ( ) ) . toEqual ( true ) ;
593+ expect ( query . getContext ( ) ) . toEqual ( {
595594 b : 2 ,
596595 c : 'hello' ,
597596 } ) ;
Original file line number Diff line number Diff line change @@ -355,6 +355,10 @@ export class SqlQuery extends SqlExpression {
355355 return SqlBase . fromValue ( value ) ;
356356 }
357357
358+ public hasContext ( ) : boolean {
359+ return Boolean ( this . contextStatements ) ;
360+ }
361+
358362 public getContext ( ) : Record < string , any > {
359363 return SqlSetStatement . contextStatementsToContext ( this . contextStatements ?. values ) ;
360364 }
Original file line number Diff line number Diff line change @@ -178,6 +178,10 @@ export class SqlWithQuery extends SqlExpression {
178178 return SqlBase . fromValue ( value ) ;
179179 }
180180
181+ public hasContext ( ) : boolean {
182+ return Boolean ( this . contextStatements ) ;
183+ }
184+
181185 public getContext ( ) : Record < string , any > {
182186 return SqlSetStatement . contextStatementsToContext ( this . contextStatements ?. values ) ;
183187 }
You can’t perform that action at this time.
0 commit comments