@param $part
@param $fieldAlias
@param $tableAlias

@return bool
766519
private function partCorrect(&$part, $fieldAlias, $tableAlias)
    {
        $result = false;
        if (is_array($part)) {
            foreach ($part as &$subPart) {
                if ($this->partCorrect($subPart, $fieldAlias, $tableAlias)) {
                    $result = true;
                }
            }

            return $result;
        }

        $partOriginal = strval($part);
        $partChanged  = preg_replace(
            '/\bl.'.$fieldAlias.' /m',
            $tableAlias.'.value ',
            $partOriginal
        );
        if (null !== $partChanged && $partChanged !== $partOriginal) {
            $part   = $partChanged;
            $result = true;
        }

        return $result;
    }
422793
public function generateSelectClause($tableAliases = [])
    {
        $sql = '';

        foreach ($this->columnOwnerMap as $columnName => $dqlAlias) {
            $tableAlias = $tableAliases[$dqlAlias] ?? $dqlAlias;

            if ($sql) {
                $sql .= ', ';
            }

            $sql .= $tableAlias . '.';

            if (isset($this->fieldMappings[$columnName])) {
                $class = $this->em->getClassMetadata($this->declaringClasses[$columnName]);
                $field = $this->fieldMappings[$columnName];
                $sql  .= $class->getProperty($field)->getColumnName();
            } elseif (isset($this->metaMappings[$columnName])) {
                $sql .= $this->metaMappings[$columnName];
            } elseif (isset($this->discriminatorColumns[$dqlAlias])) {
                $sql .= $this->discriminatorColumns[$dqlAlias];
            }

            $sql .= ' AS ' . $columnName;
        }

        return $sql;
    }
500336
private void setTableAliasForClassDescriptor(ClassDescriptor aCld, TableAlias anAlias)
    {
        if (m_cldToAlias.get(aCld) == null)
        {
            m_cldToAlias.put(aCld, anAlias);
        }    
    }
527219
public function getSQLTableAlias($tableName, $dqlAlias = '')
    {
        $tableName .= $dqlAlias ? '@[' . $dqlAlias . ']' : '';

        if (! isset($this->tableAliasMap[$tableName])) {
            $this->tableAliasMap[$tableName] = 't' . $this->tableAliasCounter++;
        }

        return $this->tableAliasMap[$tableName];
    }
1237940
private StmtTableScan resolveStmtTableScanByAlias(String tableAlias) {
        StmtTableScan tableScan = getStmtTableScanByAlias(tableAlias);
        if (tableScan != null) {
            return tableScan;
        }
        if (m_parentStmt != null) {
            // This may be a correlated subquery
            return m_parentStmt.resolveStmtTableScanByAlias(tableAlias);
        }
        return null;
    }
268143
public function setSQLTableAlias($tableName, $alias, $dqlAlias = '')
    {
        $tableName .= $dqlAlias ? '@[' . $dqlAlias . ']' : '';

        $this->tableAliasMap[$tableName] = $alias;

        return $alias;
    }
139490
protected function validatePart($part)
    {
        if (strpos($part, '=>') !== false) {
            $subs = explode('=>', $part);
            $subs = array_filter($subs);

            foreach ($subs as $sub) {
                if (!$this->validateNoSpaces($sub)) {
                    return false;
                }
            }

            return true;
        }

        return $this->validateNoSpaces($part);
    }
757419
protected function getSelectJoinColumnSQL($tableAlias, $joinColumnName, $className, $type)
    {
        $columnAlias = $this->getSQLColumnAlias($joinColumnName);

        $this->currentPersisterContext->rsm->addMetaResult('r', $columnAlias, $joinColumnName, false, $type);

        return $tableAlias . '.' . $joinColumnName . ' AS ' . $columnAlias;
    }
451740
protected function getTable(array $queryParts)
    {
        if (isset($queryParts['table'])) {
            $from =
                (isset($queryParts['fields']) && !empty($queryParts['fields'])) ||
                strtoupper($queryParts['type']) === 'DELETE' ?
                'FROM ' :
                '';

            if (is_a($queryParts['table'], 'Database\Table')) {
                $select = !empty($from) ? $from . '%s' : '%s';

                if (!empty($from) && strtoupper($queryParts['type']) !== 'DELETE') {
                    $select .= ' AS %s';
                }

                return sprintf(
                    $select,
                    $this->quoteTable($queryParts['table']->getTable()),
                    $this->quoteTable($queryParts['table']->getName())
                );
            } else {
                return $from . $this->quoteTable($queryParts['table']);
            }
        }

        return null;
    }
972573
public function getFieldsWithTableAlias($table_alias = null)
    {
        $vals = [];
        $replace = $table_alias === null ? '' : sprintf("%s.", $table_alias);

        foreach ($this->fields as $name => $definition) {
            $vals[$name] = $this->replaceToken($this->fields[$name], $replace);
        }

        return $vals;
    }
1283165
protected function getFullFieldName($field, $alias = self::DEFAULT_TABLE_ALIAS, $separator = '.')
    {
        return sprintf('%s%s%s', $alias, $separator, $field);
    }
1327248
public function stmt_fragment($part, $args=[]) {
		$type = $this->dbtype;
		if ($part == 'engine') {
			if ($type == 'mysql')
				# we only intent to support FOREIGN KEY-capable engines
				return "ENGINE=InnoDB";
			return '';
		}
		if ($part == "index") {
			if ($type == 'pgsql')
				return 'SERIAL PRIMARY KEY';
			if ($type == 'mysql')
				return 'INTEGER PRIMARY KEY AUTO_INCREMENT';
			return 'INTEGER PRIMARY KEY AUTOINCREMENT';
		}
		if ($part == 'datetime') {
			$delta = 0;
			if ($args && isset($args['delta']))
				$delta = (int)$args['delta'];
			return $this->stmt_fragment_datetime($delta);
		}
		return "";
	}
523049
public function addSimpleSelectFieldsAsAlias($field, $alias, $table = false): self
    {
        if (!$table) {
            $table = $this->getDbTableName();
        }
        // Translation field
        if (\in_array($field, $this->getTranslationFields(), true)) {
            ++$this->translation_join_count;
            $this->addJoinTable(['cms_translations', $this->getTranslationTableJoinAlias() . $this->translation_join_count], 'id', $field, 'LEFT', $table);

            $this->sql_select_fields[] = [
                'table' => $this->getTranslationTableJoinAlias() . $this->translation_join_count . '',
                'field' => $this->getLanguage(),
                'as'    => $alias,
                'type'  => TableStructure::FIELD_TYPE_TRANSLATION
            ];
        } else {
            $this->sql_select_fields[] = [
                'table' => $table,
                'field' => $field,
                'as'    => $alias,
                'type'  => 'simple'
            ];
        }

        return $this;
    }
359438
protected function _getPart($part)
    {
        if (property_exists($this, $part)) {
            return $this->{$part};
        } elseif (!in_array($part, self::$_table_parts)) {
            throw new InvalidArgumentException(
                sprintf('Unknown table part "%s"!', $part)
            );
        }
    }
474393
private function setJoin($table, $field, $parentField, $alias, $parentAlias)
    {
        if (!in_array($alias, $this->tables)) {
            $condition = $this->getFullFieldName($field, $alias).' = '.$this->getFullFieldName($parentField, $parentAlias);
            $this->queryBuilder->join($table, $alias, 'WITH', $condition);
            $this->tables[] = $alias;
        }
    }
1098740
final function Table($alias = '', array $fieldAliases = array())
    {
        $sql = $this->SqlBuilder();
        return $sql->Table($this->TableName(), $this->FieldNames($fieldAliases), $alias);
    }
735801
function isSearchPartIncomplete( $part )
    {
        if ( $this->searchHandler instanceof LegacyHandler )
        {
            $searchEngine = new eZSearchEngine();
            return $searchEngine->isSearchPartIncomplete( $part );
        }

        return false;
    }