public function changeToOuterJoin($aliases)
    {
        /* @var $join Join */
        /* @var $parent Join */
        while ($aliases) {
            $alias = array_pop($aliases);
            $join = $this->tableJoinsMap[$alias];

            // for the first join this should be true because its not a join
            // but a basetable that will be used in the from part of the query
            if (null == $join->getJoinType()) {
                continue;
            }

            // only the first alias is allowed to have null join type
            assert(null !== $join->getJoinType());

            $parentAlias = $join->getParentAlias();
            $parentIsOuter = ($parentAlias && LOUTER == $this->tableJoinsMap[$parentAlias]->getJoinType());
            $aliasIsOuter = (LOUTER == $join->getJoinType());

            if (($join->getNullable() || $parentIsOuter) && !$aliasIsOuter) {
                $this->tableJoinsMap[$alias] = $join->promote();
                // since we have just change the join type of alias we need to update
                // any thing else that refers to it
                foreach ($this->tableJoinsMap as $key => $join) {
                    if ($join->getParentAlias() == $alias &&
                        !ArrayHelper::hasKey($aliases, $key)
                    ) {
                        $aliases[] = $key;
                    }
                }
            }
        }
    }