@@ -35,7 +35,7 @@ class RiQuery extends Query {
3535
3636 condition = condition . replace ( / ( \$ | \( \) ) / g, '' ) . replace ( / @ / g, '$' ) ;
3737 condition = scripting . parseJSOL ( condition ) ;
38-
38+
3939 super ( condition , options ) ;
4040 }
4141
@@ -54,14 +54,16 @@ class RiQuery extends Query {
5454 const keys = new Set ( ) ;
5555 while ( stack ?. length > 0 ) {
5656 const currentObj = stack . pop ( ) ;
57- Object . keys ( currentObj ) . forEach ( ( key ) => {
58- const value = currentObj [ key ] ;
59- if ( ! key . startsWith ( '$' ) ) keys . add ( key ) ;
60- if ( typeof value === 'object' && value !== null ) {
61- const eles = Array . isArray ( value ) ? value : [ value ] ;
62- eles . forEach ( ( ele ) => stack . push ( ele ) ) ;
63- }
64- } ) ;
57+ if ( currentObj ) {
58+ Object . keys ( currentObj ) . forEach ( ( key ) => {
59+ const value = currentObj [ key ] ;
60+ if ( ! key . startsWith ( '$' ) ) keys . add ( key ) ;
61+ if ( typeof value === 'object' && value !== null ) {
62+ const eles = Array . isArray ( value ) ? value : [ value ] ;
63+ eles . forEach ( ( ele ) => stack . push ( ele ) ) ;
64+ }
65+ } ) ;
66+ }
6567 }
6668 return Array . from ( keys ) ;
6769 }
@@ -274,9 +276,9 @@ class RiScript {
274276
275277 options . input = expr ;
276278 expr = this . lexParseVisit ( options ) ?? '' ; // do it
277-
279+
278280 if ( trace ) {
279- console . log ( `Result(${ i } ) -> "` + `${ escapeText ( expr || '' ) } "`
281+ console . log ( `Result(${ i } ) -> "` + `${ escapeText ( expr || '' ) } "`
280282 + ` ctx=${ this . visitor . lookupsToString ( ) } ` ) ;
281283 }
282284
@@ -548,7 +550,7 @@ class RiScript {
548550 return s ;
549551 }
550552
551- // ========================= helpers ===============================
553+ // ========================= helpers ===============================
552554
553555 /** @private */
554556 _createRegexes ( tokens ) {
0 commit comments