@@ -185,10 +185,10 @@ export class Listener implements SOQLListener {
185185 console . log ( 'enterAlias_name:' , ctx . text ) ;
186186 }
187187 if ( this . context . currentItem === 'from' ) {
188- this . soqlQuery . sObjectAlias = ctx . text ;
188+ this . getSoqlQuery ( ) . sObjectAlias = ctx . text ;
189189 // All fields need to update to remove the alias from relationships
190- this . soqlQuery . fields . forEach ( field => {
191- if ( field . text . startsWith ( `${ ctx . text } .` ) ) {
190+ this . getSoqlQuery ( ) . fields . forEach ( field => {
191+ if ( field . text && field . text . startsWith ( `${ ctx . text } .` ) ) {
192192 field . alias = ctx . text ;
193193 field . text = field . text . replace ( `${ ctx . text } .` , '' ) ;
194194 if ( field . relationshipFields . length > 2 ) {
@@ -777,9 +777,15 @@ export class Listener implements SOQLListener {
777777 }
778778 this . getSoqlQuery ( ) . sObject = ctx . getChild ( 0 ) . text ;
779779 if ( this . config . includeSubqueryAsField && this . context . isSubQuery ) {
780- this . soqlQuery . fields . push ( {
781- subqueryObjName : ctx . text ,
782- } ) ;
780+ if ( ctx . getChild ( 0 ) . text . includes ( '.' ) ) {
781+ this . soqlQuery . fields . push ( {
782+ subqueryObjName : ctx . text ,
783+ } ) ;
784+ } else {
785+ this . soqlQuery . fields . push ( {
786+ subqueryObjName : ctx . getChild ( 0 ) . text ,
787+ } ) ;
788+ }
783789 }
784790 }
785791 exitObject_spec ( ctx : Parser . Object_specContext ) {
0 commit comments