Exemplo n.º 1
0
        protected void ValidateColumnExpression(QuerySpecification qs, ColumnExpression ce)
        {
            // TODO: delete
            // eliminate star queries
            /*if (ce.ColumnReference.IsStar)
            {
                throw CreateException(ExceptionMessages.StarColumnNotAllowed, null, null, ce);
            }*/

            foreach (ColumnIdentifier ci in ce.EnumerateDescendantsRecursive<ColumnIdentifier>(null))
            {
                ValidateColumnIdentifier(qs, ci);
            }

            // *** TODO: look for duplicate aliases
        }
Exemplo n.º 2
0
        public static SelectList Create(ColumnReference cr)
        {
            // Create new expression
            var nsl = new SelectList();

            var nce = new ColumnExpression();
            nce.ColumnReference = new ColumnReference(cr);
            nsl.Stack.AddLast(nce);

            var nex = new Expression();
            nce.Stack.AddLast(nex);

            var nav = new AnyVariable();
            nex.Stack.AddLast(nav);

            nav.Stack.AddLast(ColumnIdentifier.Create(new ColumnReference(cr)));

            return nsl;
        }
Exemplo n.º 3
0
        private void InitializeMembers()
        {
            this.columnExpression = null;
            this.columnIdentifier = null;
            this.tableReference = null;

            this.columnName = null;
            this.dataType = DataType.Unknown;
            this.columnAlias = null;

            this.isStar = false;
            this.isComplexExpression = false;
            this.selectListIndex = -1;
            this.columnContext = Graywulf.SqlParser.ColumnContext.None;
        }
Exemplo n.º 4
0
        private void CopyMembers(ColumnReference old)
        {
            this.columnExpression = old.columnExpression;
            this.columnIdentifier = old.columnIdentifier;
            this.tableReference = old.tableReference;

            this.columnName = old.columnName;
            this.dataType = old.dataType;
            this.columnAlias = old.columnAlias;

            this.isStar = old.isStar;
            this.isComplexExpression = old.isComplexExpression;
            this.selectListIndex = old.selectListIndex;
            this.columnContext = old.columnContext;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ce"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static ColumnReference Interpret(ColumnExpression ce)
        {
            var exp = ce.FindDescendant<Expression>();

            var cr = new ColumnReference();
            if (exp.IsSingleColumn)
            {
                cr.isComplexExpression = false;
                cr = Interpret(exp.FindDescendantRecursive<ColumnIdentifier>());
            }
            else
            {
                cr.isComplexExpression = true;
            }

            ColumnAlias ca = ce.FindDescendant<ColumnAlias>();
            if (ca != null)
            {
                cr.columnAlias = ca.Value;
            }

            cr.columnExpression = ce;

            return cr;
        }
Exemplo n.º 6
0
 public abstract bool WriteColumnExpression(ColumnExpression node);
Exemplo n.º 7
0
        /// <summary>
        /// Writes a column expression
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public virtual void WriteColumnExpression(ColumnExpression node)
        {
            // A column expression is in the form of an expression,
            // optionally followed by a column alias in the form of
            // 'AS alias'

            if (resolveNames)
            {
                // Write the expression first as it is
                var exp = node.FindDescendant<Expression>();
                WriteNode(exp);

                // If it's not a * column and there's an alias, write it
                if (!node.ColumnReference.IsStar && !String.IsNullOrEmpty(node.ColumnReference.ColumnAlias))
                {
                    Writer.Write(
                        " AS {0}",
                        QuoteIdentifier(node.ColumnReference.ColumnAlias));
                }
            }
            else
            {
                // Fall back to original behavior
                base.WriteNode(node);
            }
        }