@@ -17,18 +17,21 @@ class Sql2Generator extends BaseSqlGenerator
1717     * Selector ::= nodeTypeName ['AS' selectorName] 
1818     * nodeTypeName ::= Name 
1919     * 
20-      * @param string $nodeTypeName The node type of the selector. If it does not contain starting and ending brackets ([]) they will be added automatically 
21-      * @param string $selectorName 
20+      * @param string      $nodeTypeName The node type of the selector. If it 
21+      *      does not contain starting and ending brackets ([]) they will be 
22+      *      added automatically. 
23+      * @param string|null $selectorName The selector name. If it is different than 
24+      *      the nodeTypeName, the alias is declared. 
2225     * 
2326     * @return string 
2427     */ 
2528    public  function  evalSelector ($ nodeTypeName$ selectorNamenull )
2629    {
2730        $ sql2$ this addBracketsIfNeeded ($ nodeTypeName
2831
29-         $ name  =  $ selectorName; 
30-         if  (!  is_null ( $ name)) { 
31-             $ sql2' AS  '  . $ name 
32+         if  ( null  !==  $ selectorName  &&  $ nodeTypeName  !==  $ selectorName) { 
33+              //  if the selector  name is the same as the type name, this is implicit for sql2 
34+             $ sql2' AS  '  . $ selectorName 
3235        }
3336
3437        return  $ sql2
@@ -112,7 +115,9 @@ public function evalSameNodeJoinCondition($sel1Name, $sel2Name, $sel2Path = null
112115            . $ this addBracketsIfNeeded ($ sel1Name',  ' 
113116            . $ this addBracketsIfNeeded ($ sel2Name
114117        ;
115-         $ sql2is_null ($ sel2Path',  '  . $ sel2Path'' ;
118+         if  (null  !== $ sel2Path
119+             $ sql2',  '  . $ sel2Path
120+         }
116121        $ sql2') ' ;
117122
118123        return  $ sql2
@@ -165,7 +170,7 @@ public function evalDescendantNodeJoinCondition($descendantSelectorName, $ancest
165170    public  function  evalSameNode ($ path$ selectorNamenull )
166171    {
167172        $ sql2'ISSAMENODE( ' ;
168-         $ sql2is_null ( $ selectorName)  ? $ path$ this addBracketsIfNeeded ($ selectorName',  '  . $ path
173+         $ sql2null  ===  $ selectorName$ path$ this addBracketsIfNeeded ($ selectorName',  '  . $ path
169174        $ sql2') ' ;
170175
171176        return  $ sql2
@@ -180,7 +185,7 @@ public function evalSameNode($path, $selectorName = null)
180185    public  function  evalChildNode ($ path$ selectorNamenull )
181186    {
182187        $ sql2'ISCHILDNODE( ' ;
183-         $ sql2is_null ( $ selectorName)  ? $ path$ this addBracketsIfNeeded ($ selectorName',  '  . $ path
188+         $ sql2null  ===  $ selectorName$ path$ this addBracketsIfNeeded ($ selectorName',  '  . $ path
184189        $ sql2') ' ;
185190
186191        return  $ sql2
@@ -195,7 +200,7 @@ public function evalChildNode($path, $selectorName = null)
195200    public  function  evalDescendantNode ($ path$ selectorNamenull )
196201    {
197202        $ sql2'ISDESCENDANTNODE( ' ;
198-         $ sql2is_null ( $ selectorName)  ? $ path$ this addBracketsIfNeeded ($ selectorName',  '  . $ path
203+         $ sql2null  ===  $ selectorName$ path$ this addBracketsIfNeeded ($ selectorName',  '  . $ path
199204        $ sql2') ' ;
200205
201206        return  $ sql2
@@ -289,7 +294,7 @@ public function evalFullTextSearchScore($selectorValue = null)
289294     */ 
290295    public  function  evalPropertyValue ($ propertyName$ selectorNamenull )
291296    {
292-         $ sql2!  is_null ( $ selectorName)  ? $ this addBracketsIfNeeded ($ selectorName'. '  : '' ;
297+         $ sql2null  !==  $ selectorName$ this addBracketsIfNeeded ($ selectorName'. '  : '' ;
293298        if  (false  !== strpos ($ propertyName': ' )) {
294299            $ propertyName"[ $ propertyName] " ;
295300        }
@@ -340,11 +345,14 @@ public function evalColumns($columns)
340345    public  function  evalColumn ($ selectorName$ propertyNamenull , $ colnamenull )
341346    {
342347        $ sql2'' ;
343-         if  (!  is_null ( $ selectorName)  && is_null ( $ propertyName)  && is_null ( $ colname) ) {
348+         if  (null  !==  $ selectorNamenull  ===  $ propertyNamenull  ===  $ colname
344349            $ sql2$ this addBracketsIfNeeded ($ selectorName'.* ' ;
345350        } else  {
346351            $ sql2$ this evalPropertyValue ($ propertyName$ selectorName
347-             $ sql2is_null ($ colname' AS  '  . $ colname'' ;
352+             if  (null  !== $ colname$ colname$ propertyName
353+                 // if the column name is the same as the property name, this is implicit for sql2 
354+                 $ sql2' AS  '  . $ colname
355+             }
348356        }
349357
350358        return  $ sql2
0 commit comments