Commit 247909b8 authored by terrymanu's avatar terrymanu
Browse files

refactor DropPrimaryKeySegment

parent 27dcd2f5
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -33,10 +33,6 @@ public final class MySQLDropPrimaryKeyExtractor implements OptionalSQLSegmentExt
    
    @Override
    public Optional<DropPrimaryKeySegment> extract(final ParserRuleContext ancestorNode) {
        Optional<ParserRuleContext> dropPrimaryKeyNode = ExtractorUtils.findFirstChildNode(ancestorNode, RuleName.DROP_PRIMARY_KEY);
        if (!dropPrimaryKeyNode.isPresent()) {
            return Optional.absent();
        }
        return Optional.of(new DropPrimaryKeySegment(true));
        return ExtractorUtils.findFirstChildNode(ancestorNode, RuleName.DROP_PRIMARY_KEY).isPresent() ? Optional.of(new DropPrimaryKeySegment()) : Optional.<DropPrimaryKeySegment>absent();
    }
}
+1 −5
Original line number Diff line number Diff line
@@ -37,10 +37,6 @@ public final class OracleDropPrimaryKeyExtractor implements OptionalSQLSegmentEx
        if (!dropConstraintNode.isPresent()) {
            return Optional.absent();
        }
        Optional<ParserRuleContext> primaryKeyNode = ExtractorUtils.findFirstChildNode(dropConstraintNode.get(), RuleName.PRIMARY_KEY);
        if (!primaryKeyNode.isPresent()) {
            return Optional.absent();
        }
        return Optional.of(new DropPrimaryKeySegment(true));
        return ExtractorUtils.findFirstChildNode(dropConstraintNode.get(), RuleName.PRIMARY_KEY).isPresent() ? Optional.of(new DropPrimaryKeySegment()) : Optional.<DropPrimaryKeySegment>absent();
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ public final class DropPrimaryKeyFiller implements SQLStatementFiller<DropPrimar
    
    @Override
    public void fill(final DropPrimaryKeySegment sqlSegment, final SQLStatement sqlStatement, final String sql, final ShardingRule shardingRule, final ShardingTableMetaData shardingTableMetaData) {
        AlterTableStatement alterTableStatement = (AlterTableStatement) sqlStatement;
        alterTableStatement.setDropPrimaryKey(sqlSegment.isDropPrimaryKey());
        ((AlterTableStatement) sqlStatement).setDropPrimaryKey(true);
    }
}
+0 −6
Original line number Diff line number Diff line
@@ -18,17 +18,11 @@
package io.shardingsphere.core.parsing.antlr.sql.segment.definition.constraint;

import io.shardingsphere.core.parsing.antlr.sql.segment.SQLSegment;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * Drop primary key segment.
 * 
 * @author duhongjun
 */
@RequiredArgsConstructor
@Getter
public final class DropPrimaryKeySegment implements SQLSegment {
    
    private final boolean dropPrimaryKey;
}