-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor SQLBindEngine * Refactor SQLBindEngine
- Loading branch information
Showing
3 changed files
with
128 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...der/src/main/java/org/apache/shardingsphere/infra/binder/type/DDLStatementBindEngine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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.infra.binder.type; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.apache.shardingsphere.infra.binder.statement.ddl.CursorStatementBinder; | ||
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.CursorStatement; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DDLStatement; | ||
|
||
/** | ||
* DDL statement bind engine. | ||
*/ | ||
@RequiredArgsConstructor | ||
public final class DDLStatementBindEngine { | ||
|
||
private final ShardingSphereMetaData metaData; | ||
|
||
private final String currentDatabaseName; | ||
|
||
/** | ||
* Bind DDL statement. | ||
* | ||
* @param statement to be bound DDL statement | ||
* @return bound DDL statement | ||
*/ | ||
public DDLStatement bind(final DDLStatement statement) { | ||
if (statement instanceof CursorStatement) { | ||
return new CursorStatementBinder().bind((CursorStatement) statement, metaData, currentDatabaseName); | ||
} | ||
return statement; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...der/src/main/java/org/apache/shardingsphere/infra/binder/type/DMLStatementBindEngine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* 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.infra.binder.type; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.apache.shardingsphere.infra.binder.statement.dml.DeleteStatementBinder; | ||
import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementBinder; | ||
import org.apache.shardingsphere.infra.binder.statement.dml.MergeStatementBinder; | ||
import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementBinder; | ||
import org.apache.shardingsphere.infra.binder.statement.dml.UpdateStatementBinder; | ||
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.DMLStatement; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.DeleteStatement; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.InsertStatement; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.MergeStatement; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.SelectStatement; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.UpdateStatement; | ||
|
||
/** | ||
* DML statement bind engine. | ||
*/ | ||
@RequiredArgsConstructor | ||
public final class DMLStatementBindEngine { | ||
|
||
private final ShardingSphereMetaData metaData; | ||
|
||
private final String currentDatabaseName; | ||
|
||
/** | ||
* Bind DML statement. | ||
* | ||
* @param statement to be bound DML statement | ||
* @return bound DML statement | ||
*/ | ||
public DMLStatement bind(final DMLStatement statement) { | ||
if (statement instanceof SelectStatement) { | ||
return new SelectStatementBinder().bind((SelectStatement) statement, metaData, currentDatabaseName); | ||
} | ||
if (statement instanceof InsertStatement) { | ||
return new InsertStatementBinder().bind((InsertStatement) statement, metaData, currentDatabaseName); | ||
} | ||
if (statement instanceof UpdateStatement) { | ||
return new UpdateStatementBinder().bind((UpdateStatement) statement, metaData, currentDatabaseName); | ||
} | ||
if (statement instanceof DeleteStatement) { | ||
return new DeleteStatementBinder().bind((DeleteStatement) statement, metaData, currentDatabaseName); | ||
} | ||
if (statement instanceof MergeStatement) { | ||
return new MergeStatementBinder().bind((MergeStatement) statement, metaData, currentDatabaseName); | ||
} | ||
return statement; | ||
} | ||
} |