示例#1
0
            private void HandleDotStructure(IASTNode dotStructureRoot)
            {
                var expression = ASTUtil.GetPathText(dotStructureRoot);

                var constant = ReflectHelper.GetConstantValue(expression, _sfi);

                if (constant != null)
                {
                    dotStructureRoot.ClearChildren();
                    dotStructureRoot.Type = HqlSqlWalker.JAVA_CONSTANT;
                    dotStructureRoot.Text = expression;
                }
            }
        private void MutateRowValueConstructorSyntax(int operandColumnSpan)
        {
            int    comparisonType = Type;
            string comparisonText = Text;

            int    expansionConnectorType = ExpansionConnectorType;
            string expansionConnectorText = ExpansionConnectorText;

            Type = expansionConnectorType;
            Text = expansionConnectorText;

            String[] mutationTexts = ExtractMutationTexts(Operand, operandColumnSpan);

            IASTNode container = this;

            container.ClearChildren();

            for (int i = operandColumnSpan - 1; i > 0; i--)
            {
                if (i == 1)
                {
                    var op1      = ASTFactory.CreateNode(comparisonType, comparisonText);
                    var operand1 = ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, mutationTexts[0]);
                    op1.SetFirstChild(operand1);
                    container.SetFirstChild(op1);

                    var op2      = ASTFactory.CreateNode(comparisonType, comparisonText);
                    var operand2 = ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, mutationTexts[1]);
                    op2.SetFirstChild(operand2);
                    op1.AddSibling(op2);
                }
                else
                {
                    var operand = ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, mutationTexts[i]);
                    var op      = ASTFactory.CreateNode(comparisonType, comparisonText);
                    op.SetFirstChild(operand);

                    var newContainer = ASTFactory.CreateNode(expansionConnectorType, expansionConnectorText);
                    container.SetFirstChild(newContainer);
                    newContainer.AddSibling(op);
                    container = newContainer;
                }
            }
        }
        private void MutateRowValueConstructorSyntax(int operandColumnSpan)
        {
            int    comparisonType = Type;
            string comparisonText = Text;

            int    expansionConnectorType = ExpansionConnectorType;
            string expansionConnectorText = ExpansionConnectorText;

            Type = expansionConnectorType;
            Text = expansionConnectorText;

            String[] mutationTexts = ExtractMutationTexts(Operand, operandColumnSpan);

            IASTNode container = this;

            container.ClearChildren();

            for (int i = operandColumnSpan - 1; i > 0; i--)
            {
                if (i == 1)
                {
                    container.AddChildren(
                        ASTFactory.CreateNode(comparisonType, comparisonText,
                                              ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, mutationTexts[0])),
                        ASTFactory.CreateNode(comparisonType, comparisonText,
                                              ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, mutationTexts[1])));
                }
                else
                {
                    container.AddChildren(
                        ASTFactory.CreateNode(expansionConnectorType, expansionConnectorText),
                        ASTFactory.CreateNode(comparisonType, comparisonText,
                                              ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, mutationTexts[i])));

                    container = GetChild(0);
                }
            }
        }
			private void HandleDotStructure(IASTNode dotStructureRoot)
			{
				var expression = ASTUtil.GetPathText(dotStructureRoot);

				var constant = ReflectHelper.GetConstantValue(expression, _sfi);

				if (constant != null)
				{
					dotStructureRoot.ClearChildren();
					dotStructureRoot.Type = HqlSqlWalker.JAVA_CONSTANT;
					dotStructureRoot.Text = expression;
				}
			}
示例#5
0
 public void ClearChildren()
 {
     _children.Clear();
     _node.ClearChildren();
 }
示例#6
0
        /**
         * Mutate the subtree relating to a row-value-constructor to instead use
         * a series of ANDed predicates.  This allows multi-column type comparisons
         * and explicit row-value-constructor syntax even on databases which do
         * not support row-value-constructor.
         * <p/>
         * For example, here we'd mutate "... where (col1, col2) = ('val1', 'val2) ..." to
         * "... where col1 = 'val1' and col2 = 'val2' ..."
         *
         * @param valueElements The number of elements in the row value constructor list.
         */
        private void MutateRowValueConstructorSyntax(int valueElements)
        {
            // mutation depends on the types of nodes invloved...
            int    comparisonType = Type;
            string comparisonText = Text;

            Type = HqlSqlWalker.AND;
            Text = "AND";

            String[] lhsElementTexts = ExtractMutationTexts(LeftHandOperand, valueElements);
            String[] rhsElementTexts = ExtractMutationTexts(RightHandOperand, valueElements);

            IParameterSpecification lhsEmbeddedCompositeParameterSpecification =
                LeftHandOperand == null || (!(LeftHandOperand is ParameterNode))
                                                        ? null
                                                        : (( ParameterNode )LeftHandOperand).HqlParameterSpecification;

            IParameterSpecification rhsEmbeddedCompositeParameterSpecification =
                RightHandOperand == null || (!(RightHandOperand is ParameterNode))
                                                        ? null
                                                        : (( ParameterNode )RightHandOperand).HqlParameterSpecification;

            IASTNode container = this;

            for (int i = valueElements - 1; i > 0; i--)
            {
                if (i == 1)
                {
                    container.ClearChildren();

                    container.AddChildren(
                        ASTFactory.CreateNode(
                            comparisonType, comparisonText,
                            ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, lhsElementTexts[0]),
                            ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, rhsElementTexts[0])
                            ),
                        ASTFactory.CreateNode(
                            comparisonType, comparisonText,
                            ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, lhsElementTexts[1]),
                            ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, rhsElementTexts[1])
                            ));

                    // "pass along" our initial embedded parameter node(s) to the first generated
                    // sql fragment so that it can be handled later for parameter binding...
                    SqlFragment fragment = ( SqlFragment )container.GetChild(0).GetChild(0);
                    if (lhsEmbeddedCompositeParameterSpecification != null)
                    {
                        fragment.AddEmbeddedParameter(lhsEmbeddedCompositeParameterSpecification);
                    }
                    if (rhsEmbeddedCompositeParameterSpecification != null)
                    {
                        fragment.AddEmbeddedParameter(rhsEmbeddedCompositeParameterSpecification);
                    }
                }
                else
                {
                    container.ClearChildren();
                    container.AddChildren(
                        ASTFactory.CreateNode(HqlSqlWalker.AND, "AND"),
                        ASTFactory.CreateNode(
                            comparisonType, comparisonText,
                            ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, lhsElementTexts[i]),
                            ASTFactory.CreateNode(HqlSqlWalker.SQL_TOKEN, rhsElementTexts[i])
                            ));

                    container = container.GetChild(0);
                }
            }
        }