Exemple #1
0
        static Expression MakeNotNullCheck(ExpressionItem list)
        {
            Expression top = null;

            while (list != null)
            {
                INode term = TailorUtil.GetTerm(list.Expression);
                if (!(term is IntegerValue) && !(term is StringValue))
                {
                    Expression leaf = new Expression();
                    leaf.Left     = term.Clone();
                    leaf.Operator = ExpressionOperator.IsNotNull;

                    if (top == null)
                    {
                        top = leaf;
                    }
                    else
                    {
                        top = new Expression(top, ExpressionOperator.Or, leaf);
                    }
                }

                list = list.Next;
            }

            return(top);
        }
Exemple #2
0
        static INode MakeNotNullCheck(ExpressionItem list)
        {
            INode top = null;

            while (list != null)
            {
                INode        term         = TailorUtil.GetTerm(list.Expression);
                IntegerValue integerValue = term as IntegerValue;
                if (integerValue == null)
                {
                    FunctionCall leaf = new FunctionCall("IsNull");
                    leaf.ExpressionArguments = new ExpressionItem(term.Clone());

                    if (top == null)
                    {
                        top = leaf;
                    }
                    else
                    {
                        top = new Expression(top, ExpressionOperator.Or, leaf);
                    }
                }

                list = list.Next;
            }

            return(top);
        }
Exemple #3
0
        public override void PerformBefore(QueryExpression node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            base.PerformBefore(node);

            if (node.Where == null)
            {
                AliasedItem from = node.From;
                if ((from != null) && (from.Alias == null) && !from.HasNext)
                {
                    Table singleTable = from.Item as Table;
                    if ((singleTable != null) && (singleTable.Alias == null) &&
                        (singleTable.JoinCondition == null) &&
                        (singleTable.JoinType == null) && !singleTable.HasNext)
                    {
                        DbObject singleName = TailorUtil.GetTerm(
                            singleTable.Source) as DbObject;
                        if ((singleName != null) && !singleName.HasNext)
                        {
                            Identifier identifier = singleName.Identifier;

                            // Not canonicalizing - we're accepting quoted "dual"
                            // as a regular identifier.
                            if (TailorUtil.DUAL.Equals(
                                    identifier.ID.ToLowerInvariant()))
                            {
                                node.From = null;
                            }
                        }
                    }
                }
            }

            if (node.LimitFormat != ' ')
            {
                node.LimitFormat = 'L';
            }
        }