} // toStringNoAlias()

        private void appendJoinOnItem(StringBuilder sb, String sideAlias, SelectItem onItem)
        {
            FromItem fromItem = onItem.getFromItem();

            if (fromItem != null && fromItem.getSubQuery() != null && fromItem.getAlias() != null)
            {
                // there's a corner case scenario where an ON item references a
                // subquery being joined. In that case the getSuperQueryAlias()
                // method will include the subquery alias.
                string super_query_alias = onItem.getSuperQueryAlias();
                sb.Append(super_query_alias);
                return;
            }

            if (_join != JoinType.None && _leftSide.getJoin() != JoinType.None)
            {
                sb.Append(onItem.toSql());
                return;
            }

            if (sideAlias != null)
            {
                sb.Append(sideAlias);
                sb.Append('.');
            }
            String superQueryAlias = onItem.getSuperQueryAlias();

            sb.Append(superQueryAlias);
        } // appendJoinOnItem()
예제 #2
0
        public StringBuilder toStringNoAlias(bool?includeSchemaInColumnPath)
        {
            StringBuilder sb = new StringBuilder();

            if (_column != null)
            {
                sb.Append(getToStringColumnPrefix(includeSchemaInColumnPath));
                sb.Append(_column.getQuotedName());
            }
            if (_expression != null)
            {
                sb.Append(_expression);
            }
            if (_fromItem != null && _subQuerySelectItem != null)
            {
                if (_fromItem.getAlias() != null)
                {
                    sb.Append(_fromItem.getAlias() + '.');
                }
                sb.Append(_subQuerySelectItem.getSuperQueryAlias());
            }
            if (_function != null)
            {
                StringBuilder functionBeginning = new StringBuilder();
                if (_functionApproximationAllowed)
                {
                    functionBeginning.Append(FUNCTION_APPROXIMATION_PREFIX);
                }

                functionBeginning.Append(_function.getFunctionName());
                functionBeginning.Append('(');
                object[] functionParameters = getFunctionParameters();
                if (functionParameters != null && functionParameters.Length != 0)
                {
                    for (int i = 0; i < functionParameters.Length; i++)
                    {
                        functionBeginning.Append('\'');
                        functionBeginning.Append(functionParameters[i]);
                        functionBeginning.Append('\'');
                        functionBeginning.Append(',');
                    }
                }
                sb.Insert(0, functionBeginning.ToString());
                sb.Append(")");
            }
            return(sb);
        } // toStringNoAlias()
        } // appendJoinOnItem()

        /**
         * Gets the alias of a table, if it is registered (and visible, ie. not part
         * of a sub-query) in the FromItem
         *
         * @param table
         *            the table to get the alias for
         * @return the alias or null if none is found
         */
        public String getAlias(Table table)
        {
            String result = null;

            if (table != null)
            {
                // Search recursively through left and right side, unless they
                // are sub-query FromItems
                if (table.Equals(_table))
                {
                    result = _alias;
                }
                else if (_join != JoinType.None)
                {
                    result = _rightSide.getAlias(table);
                    if (result == null)
                    {
                        result = _leftSide.getAlias(table);
                    }
                }
            }
            return(result);
        } // getAlias()