コード例 #1
0
        /// <inheritdoc/>
        protected override ISqlNode OnChildNode(ISqlNode node)
        {
            if (node.NodeName.Equals("name_part")) {
                node = node.ChildNodes.FirstOrDefault();
            }

            string text;
            if (node is IdentifierNode) {
                var idNode = (IdentifierNode) node;
                text = idNode.Text;
            } else if (node is SqlKeyNode) {
                text = ((SqlKeyNode) node).Text;

                if (!String.Equals(text, "*"))
                    throw new SqlParseException(String.Format("Invalid object name part '{0}' provided.", text));
            } else {
                throw new SqlParseException(String.Format("The node of type '{0}' is not allowed.", node.GetType()));
            }

            if (Name != null) {
                Name = String.Format("{0}.{1}", Name, text);
            } else {
                Name = text;
            }

            return base.OnChildNode(node);
        }
コード例 #2
0
        public bool AssertIsScalarExpression(ISqlNode parent, string name, ISqlNode child)
        {
            if (!AssertNotNull(parent, name, child))
            {
                return(false);
            }
            var childType = child.GetType();

            // TODO: Fix this
            if (!new[]
            {
                typeof(SqlNumberNode), typeof(SqlNullNode), typeof(SqlInfixOperationNode),
                typeof(SqlPrefixOperationNode), typeof(SqlStringNode),
                typeof(SqlIdentifierNode), typeof(SqlQualifiedIdentifierNode), typeof(SqlVariableNode)
            }.Contains(childType))
            {
                return(AddError(parent, name, "Is not an acceptable scalar expression node"));
            }

            return(true);
        }
コード例 #3
0
ファイル: ObjectNameNode.cs プロジェクト: meikeric/deveeldb
        /// <inheritdoc/>
        protected override ISqlNode OnChildNode(ISqlNode node)
        {
            if (node.NodeName.Equals("name_part"))
            {
                node = node.ChildNodes.FirstOrDefault();
            }

            string text;

            if (node is IdentifierNode)
            {
                var idNode = (IdentifierNode)node;
                text = idNode.Text;
            }
            else if (node is SqlKeyNode)
            {
                text = ((SqlKeyNode)node).Text;

                if (!String.Equals(text, "*"))
                {
                    throw new SqlParseException(String.Format("Invalid object name part '{0}' provided.", text));
                }
            }
            else
            {
                throw new SqlParseException(String.Format("The node of type '{0}' is not allowed.", node.GetType()));
            }

            if (Name != null)
            {
                Name = String.Format("{0}.{1}", Name, text);
            }
            else
            {
                Name = text;
            }

            return(base.OnChildNode(node));
        }
コード例 #4
0
 public bool AddError(ISqlNode parent, string name, string message)
 {
     _errors.Add($"{parent.GetType().Name}.{name}: {message}");
     return(false);
 }
コード例 #5
0
 public bool UnexpectedNodeType(ISqlNode parent, string name, ISqlNode child)
 {
     return(AddError(parent, name, $"{child.GetType().Name} is an unexpected node type"));
 }