1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00

Adding the ability to alias new object expressions

This commit is contained in:
James Murray 2014-10-28 17:34:57 -04:00
parent 20c6bfd360
commit 85eac7200d

View file

@ -1353,7 +1353,8 @@ class SqlWalker implements TreeWalker
break; break;
case ($expr instanceof AST\NewObjectExpression): case ($expr instanceof AST\NewObjectExpression):
$sql .= $this->walkNewObject($expr); $resultAlias = $selectExpression->fieldIdentificationVariable ?: null;
$sql .= $this->walkNewObject($expr,$resultAlias);
break; break;
default: default:
@ -1519,10 +1520,10 @@ class SqlWalker implements TreeWalker
* *
* @return string The SQL. * @return string The SQL.
*/ */
public function walkNewObject($newObjectExpression) public function walkNewObject($newObjectExpression, $newObjectResultAlias=null)
{ {
$sqlSelectExpressions = array(); $sqlSelectExpressions = array();
$objIndex = $this->newObjectCounter++; $objIndex = $newObjectResultAlias?:$this->newObjectCounter++;
foreach ($newObjectExpression->args as $argIndex => $e) { foreach ($newObjectExpression->args as $argIndex => $e) {
$resultAlias = $this->scalarResultCounter++; $resultAlias = $this->scalarResultCounter++;