/**
  * @test
  */
 public function addSelectDoesNotQuoteStarPlaceholder()
 {
     $this->connection->quoteIdentifier('aField')->shouldBeCalled()->willReturnArgument(0);
     $this->connection->quoteIdentifier('*')->shouldNotBeCalled();
     $this->concreteQueryBuilder->addSelect(Argument::exact('aField'), Argument::exact('*'))->shouldBeCalled()->willReturn($this->subject);
     $this->subject->addSelect('aField', '*');
 }
Example #2
0
 /**
  * Transforms a Join into SQL and parameter arrays
  *
  * @param Qom\JoinInterface $join The join
  * @param string $leftTableAlias The alias from the table to main
  * @return void
  */
 protected function parseJoin(Qom\JoinInterface $join, $leftTableAlias)
 {
     $leftSource = $join->getLeft();
     $leftClassName = $leftSource->getNodeTypeName();
     $this->addRecordTypeConstraint($leftClassName);
     $rightSource = $join->getRight();
     if ($rightSource instanceof Qom\JoinInterface) {
         $left = $rightSource->getLeft();
         $rightClassName = $left->getNodeTypeName();
         $rightTableName = $left->getSelectorName();
     } else {
         $rightClassName = $rightSource->getNodeTypeName();
         $rightTableName = $rightSource->getSelectorName();
         $this->queryBuilder->addSelect($rightTableName . '.*');
     }
     $this->addRecordTypeConstraint($rightClassName);
     $rightTableAlias = $this->getUniqueAlias($rightTableName);
     $joinCondition = $join->getJoinCondition();
     $joinConditionExpression = null;
     $this->unionTableAliasCache[] = $rightTableAlias;
     if ($joinCondition instanceof Qom\EquiJoinCondition) {
         $column1Name = $this->dataMapper->convertPropertyNameToColumnName($joinCondition->getProperty1Name(), $leftClassName);
         $column2Name = $this->dataMapper->convertPropertyNameToColumnName($joinCondition->getProperty2Name(), $rightClassName);
         $joinConditionExpression = $this->queryBuilder->expr()->eq($leftTableAlias . '.' . $column1Name, $rightTableAlias . '.' . $column2Name);
     }
     $this->queryBuilder->leftJoin($leftTableAlias, $rightTableName, $rightTableAlias, $joinConditionExpression);
     if ($rightSource instanceof Qom\JoinInterface) {
         $this->parseJoin($rightSource, $rightTableAlias);
     }
 }