Commit 6a95d27f authored by terrymanu's avatar terrymanu
Browse files

for #2084, merge EncryptWhereFiller & ShardingWhereFiller to WhereFiller

parent 56650def
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 * limitations under the License.
 */

package org.apache.shardingsphere.core.parse.antlr.filler.encrypt.dml;
package org.apache.shardingsphere.core.parse.antlr.filler.common.dml;

import org.apache.shardingsphere.core.parse.antlr.filler.api.SQLSegmentFiller;
import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.WhereSegment;
@@ -23,11 +23,12 @@ import org.apache.shardingsphere.core.parse.antlr.sql.statement.SQLStatement;
import org.apache.shardingsphere.core.parse.antlr.sql.statement.dml.DeleteStatement;

/**
 * Where filler for encrypt.
 * Where filler.
 *
 * @author duhongjun
 * @author zhangliang
 */
public final class EncryptWhereFiller implements SQLSegmentFiller<WhereSegment> {
public final class WhereFiller implements SQLSegmentFiller<WhereSegment> {
    
    @Override
    public void fill(final WhereSegment sqlSegment, final SQLStatement sqlStatement) {
+0 −43
Original line number Diff line number Diff line
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */

package org.apache.shardingsphere.core.parse.antlr.filler.sharding.dml;

import org.apache.shardingsphere.core.parse.antlr.filler.api.SQLSegmentFiller;
import org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.WhereSegment;
import org.apache.shardingsphere.core.parse.antlr.sql.statement.SQLStatement;
import org.apache.shardingsphere.core.parse.antlr.sql.statement.dml.DeleteStatement;

/**
 * Where filler for sharding.
 *
 * @author duhongjun
 */
public final class ShardingWhereFiller implements SQLSegmentFiller<WhereSegment> {
    
    @Override
    public void fill(final WhereSegment sqlSegment, final SQLStatement sqlStatement) {
        sqlStatement.setParametersIndex(sqlSegment.getParameterCount());
        if (sqlStatement instanceof DeleteStatement) {
            DeleteStatement deleteStatement = (DeleteStatement) sqlStatement;
            deleteStatement.setWhereStartIndex(sqlSegment.getWhereStartIndex());
            deleteStatement.setWhereStopIndex(sqlSegment.getWhereStopIndex());
            deleteStatement.setWhereParameterStartIndex(sqlSegment.getWhereParameterStartIndex());
            deleteStatement.setWhereParameterEndIndex(sqlSegment.getWhereParameterEndIndex());
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.ddl.constraint.DropPrimaryKeySegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.common.ddl.alter.DropPrimaryKeyFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.column.InsertColumnsSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.common.dml.InsertColumnsFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.SelectItemsSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.common.dql.SelectItemsFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.WhereSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.common.dml.WhereFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.order.GroupBySegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.common.dql.GroupByFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.order.OrderBySegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.common.dql.OrderByFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.limit.LimitSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.common.dql.LimitFiller" />
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.InsertValuesSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.sharding.dml.insert.InsertValuesFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.assignment.SetAssignmentsSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.sharding.dml.ShardingSetAssignmentsFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.column.OnDuplicateKeyColumnsSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.sharding.dml.insert.OnDuplicateKeyColumnsFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.WhereSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.sharding.dml.ShardingWhereFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.predicate.OrPredicateSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.sharding.dml.ShardingOrPredicateFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.predicate.SubqueryPredicateSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.sharding.dml.select.SubqueryPredicateFiller" />
</filler-rule-definition>
+0 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@

<filler-rule-definition>
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.common.TableSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.encrypt.EncryptTableFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.WhereSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.encrypt.dml.EncryptWhereFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.predicate.OrPredicateSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.encrypt.dml.EncryptOrPredicateFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.InsertValuesSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.encrypt.dml.insert.EncryptInsertValuesFiller" />
    <filler-rule sql-segment-class="org.apache.shardingsphere.core.parse.antlr.sql.segment.dml.assignment.SetAssignmentsSegment" filler-class="org.apache.shardingsphere.core.parse.antlr.filler.encrypt.dml.EncryptSetAssignmentsFiller" />
Loading