terrymanu commented on code in PR #19841: URL: https://github.com/apache/shardingsphere/pull/19841#discussion_r937921725
########## shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProvider.java: ########## @@ -0,0 +1,118 @@ +/* + * 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.mode.repository.standalone.jdbc; + +import org.apache.shardingsphere.spi.annotation.SingletonSPI; +import org.apache.shardingsphere.spi.type.typed.TypedSPI; + +/** + * JDBC repository provider. + */ +@SingletonSPI +public interface JDBCRepositoryProvider extends TypedSPI { Review Comment: Please do not use default impl, the dialect's SQL are different. For example: the escape char ` is only for MySQL and H2 ########## shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProvider.java: ########## @@ -0,0 +1,118 @@ +/* + * 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.mode.repository.standalone.jdbc; + +import org.apache.shardingsphere.spi.annotation.SingletonSPI; +import org.apache.shardingsphere.spi.type.typed.TypedSPI; + +/** + * JDBC repository provider. + */ +@SingletonSPI +public interface JDBCRepositoryProvider extends TypedSPI { + + /** + * Drop table SQL. + * + * @return SQL to drop table + */ + default String dropTableSQL() { + return "DROP TABLE IF EXISTS repository"; + } + + /** + * Create table SQL. + * + * @return SQL to create table + */ + default String createTableSQL() { + return "CREATE TABLE repository(id varchar(36) PRIMARY KEY, `key` TEXT, `value` TEXT, parent TEXT)"; + } + + /** + * Select by key SQL. + * + * @return SQL to select table + */ + default String selectByKeySQL() { + return "SELECT `value` FROM repository WHERE `key` = ?"; + } + + /** + * Select by parent key SQL. + * + * @return SQL to select table + */ + default String selectByParentKeySQL() { + return "SELECT `key` FROM repository WHERE parent = ?"; + } + + /** + * Insert SQL. + * + * @return SQL to insert table + */ + default String insertSQL() { + return "INSERT INTO repository VALUES(?, ?, ?, ?)"; + } + + /** + * Update SQL. + * + * @return SQL to update table + */ + default String updateSQL() { + return "UPDATE repository SET `value` = ? WHERE `key` = ?"; + } + + /** + * Delete SQL. + * + * @return SQL to delete table + */ + default String deleteSQL() { + return "UPDATE repository SET `value` = ? WHERE `key` = ?"; + } + + /** + * Get default JDBC url. + * + * @return Default JDBC url + */ + default String getDefaultJDBCUrl() { + return ""; + } + + /** + * Get default user. + * + * @return Default user + */ + default String getDefaultUser() { Review Comment: User and password should configured by properties ########## shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProvider.java: ########## @@ -0,0 +1,118 @@ +/* + * 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.mode.repository.standalone.jdbc; + +import org.apache.shardingsphere.spi.annotation.SingletonSPI; +import org.apache.shardingsphere.spi.type.typed.TypedSPI; + +/** + * JDBC repository provider. + */ +@SingletonSPI +public interface JDBCRepositoryProvider extends TypedSPI { + + /** + * Drop table SQL. + * + * @return SQL to drop table + */ + default String dropTableSQL() { + return "DROP TABLE IF EXISTS repository"; Review Comment: Please add escape char to table name too. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
