Commit 0c85b3a0 authored by terrymanu's avatar terrymanu
Browse files

rename SetAutoCommitExtractor

parent eeaad2f5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ public final class PredicateExtractor implements OptionalSQLSegmentExtractor {
            Integer index = questionNodeIndexMap.get(expressionNode.get());
            commonExpressionSegment.setIndex(index);
        } else {
            Optional<ParserRuleContext> bitExprNode = ExtractorUtils.findFirstChildNode(valueNode, RuleName.BITEXPR);
            Optional<ParserRuleContext> bitExprNode = ExtractorUtils.findFirstChildNode(valueNode, RuleName.BIT_EXPR);
            expressionNode = ExtractorUtils.findFirstChildNode(valueNode, RuleName.NUMBER);
            if (expressionNode.isPresent() && (!bitExprNode.isPresent() || 1 == bitExprNode.get().getChildCount())) {
                commonExpressionSegment.setValue(NumberUtil.getExactlyNumber(expressionNode.get().getText(), 10));
+3 −3
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 * </p>
 */

package io.shardingsphere.core.parsing.antlr.extractor.impl.dialect.mysql;
package io.shardingsphere.core.parsing.antlr.extractor.impl;

import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
@@ -27,11 +27,11 @@ import io.shardingsphere.core.util.SQLUtil;
import org.antlr.v4.runtime.ParserRuleContext;

/**
 * Auto commit value clause extractor for MySQL.
 * Set auto commit extractor.
 *
 * @author maxiaoguang
 */
public final class MySQLAutoCommitValueExtractor implements OptionalSQLSegmentExtractor {
public final class SetAutoCommitExtractor implements OptionalSQLSegmentExtractor {
    
    @Override
    public Optional<SetAutoCommitSegment> extract(final ParserRuleContext ancestorNode) {
+0 −43
Original line number Diff line number Diff line
/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */

package io.shardingsphere.core.parsing.antlr.extractor.impl.dialect.sqlserver;

import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.shardingsphere.core.parsing.antlr.extractor.OptionalSQLSegmentExtractor;
import io.shardingsphere.core.parsing.antlr.extractor.util.ExtractorUtils;
import io.shardingsphere.core.parsing.antlr.extractor.util.RuleName;
import io.shardingsphere.core.parsing.antlr.sql.segment.tcl.SetAutoCommitSegment;
import io.shardingsphere.core.parsing.lexer.token.DefaultKeyword;
import io.shardingsphere.core.util.SQLUtil;
import org.antlr.v4.runtime.ParserRuleContext;

/**
 * Auto commit value clause extractor for SQLServer.
 *
 * @author maxiaoguang
 */
public final class SQLServerAutoCommitValueExtractor implements OptionalSQLSegmentExtractor {
    
    @Override
    public Optional<SetAutoCommitSegment> extract(final ParserRuleContext ancestorNode) {
        Optional<ParserRuleContext> autoCommitValueNode = ExtractorUtils.findFirstChildNode(ancestorNode, RuleName.AUTO_COMMIT_VALUE);
        Preconditions.checkState(autoCommitValueNode.isPresent(), "Auto commit value is necessary.");
        return Optional.of(new SetAutoCommitSegment(DefaultKeyword.ON.name().equalsIgnoreCase(SQLUtil.getExactlyValue(autoCommitValueNode.get().getText()))));
    }
}
+10 −12
Original line number Diff line number Diff line
@@ -95,8 +95,18 @@ public enum RuleName {
    
    ALIAS("Alias"),
    
    QUESTION("Question"),
    
    NUMBER("Number"),
    
    STRING("String"),
    
    EXPR("Expr"),
    
    SIMPLE_EXPR("SimpleExpr"),
    
    BIT_EXPR("BitExpr"),
    
    FROM_CLAUSE("FromClause"),
    
    WHERE_CLAUSE("WhereClause"),
@@ -111,16 +121,6 @@ public enum RuleName {
    
    PREDICATE("Predicate"),
    
    BITEXPR("BitExpr"),
    
    QUESTION("Question"),
    
    NUMBER("Number"),
    
    STRING("String"),
    
    SIMPLE_EXPR("SimpleExpr"),
    
    LIMIT_CLAUSE("LimitClause"),
    
    RANGE_CLAUSE("RangeClause"),
@@ -129,8 +129,6 @@ public enum RuleName {
    
    SHOW_PARAM("ShowParam"),
    
    SET_AUTO_COMMIT("SetAutoCommit"),
    
    AUTO_COMMIT_VALUE("AutoCommitValue");
    
    private final String name;
+1 −1
Original line number Diff line number Diff line
@@ -4,5 +4,5 @@
    <extractor-rule id="modifyColumnDefinition" extractor-class="dialect.mysql.definition.column.MySQLModifyColumnDefinitionExtractor" />
    <extractor-rule id="changeColumnDefinition" extractor-class="dialect.mysql.definition.column.MySQLChangeColumnDefinitionExtractor" />
    <extractor-rule id="dropPrimaryKey" extractor-class="dialect.mysql.definition.constraint.MySQLDropPrimaryKeyExtractor" />
    <extractor-rule id="autoCommitValue" extractor-class="dialect.mysql.MySQLAutoCommitValueExtractor" />
    <extractor-rule id="setAutoCommit" extractor-class="SetAutoCommitExtractor" />
</extractor-rule-definition>
Loading