This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new e719139f006 Add SQLDialectFactoryTest (#37335)
e719139f006 is described below
commit e719139f006dfe339d39d2c4f82a7c2a38ca963f
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Dec 11 00:34:52 2025 +0800
Add SQLDialectFactoryTest (#37335)
---
.../sql/dialect/SQLDialectFactoryTest.java | 42 ++++++++++++++++++++++
.../dialect/impl/CustomMySQLSQLDialectTest.java | 33 +++++++++++++++++
.../impl/CustomPostgreSQLSQLDialectTest.java | 33 +++++++++++++++++
3 files changed, 108 insertions(+)
diff --git
a/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/sql/dialect/SQLDialectFactoryTest.java
b/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/sql/dialect/SQLDialectFactoryTest.java
new file mode 100644
index 00000000000..d382c45b45e
--- /dev/null
+++
b/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/sql/dialect/SQLDialectFactoryTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.sqlfederation.compiler.sql.dialect;
+
+import org.apache.calcite.sql.dialect.MssqlSqlDialect;
+import org.apache.calcite.sql.dialect.MysqlSqlDialect;
+import org.apache.calcite.sql.dialect.OracleSqlDialect;
+import
org.apache.shardingsphere.sqlfederation.compiler.sql.dialect.impl.CustomMySQLSQLDialect;
+import
org.apache.shardingsphere.sqlfederation.compiler.sql.dialect.impl.CustomPostgreSQLSQLDialect;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+class SQLDialectFactoryTest {
+
+ @Test
+ void assertGetSQLDialect() {
+ assertThat(SQLDialectFactory.getSQLDialect("MySQL"),
is(CustomMySQLSQLDialect.DEFAULT));
+ assertThat(SQLDialectFactory.getSQLDialect("H2"),
is(CustomMySQLSQLDialect.DEFAULT));
+ assertThat(SQLDialectFactory.getSQLDialect("PostgreSQL"),
is(CustomPostgreSQLSQLDialect.DEFAULT));
+ assertThat(SQLDialectFactory.getSQLDialect("openGauss"),
is(CustomPostgreSQLSQLDialect.DEFAULT));
+ assertThat(SQLDialectFactory.getSQLDialect("Oracle"),
is(OracleSqlDialect.DEFAULT));
+ assertThat(SQLDialectFactory.getSQLDialect("SQLServer"),
is(MssqlSqlDialect.DEFAULT));
+ assertThat(SQLDialectFactory.getSQLDialect("UnknownDB"),
is(MysqlSqlDialect.DEFAULT));
+ }
+}
diff --git
a/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/sql/dialect/impl/CustomMySQLSQLDialectTest.java
b/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/sql/dialect/impl/CustomMySQLSQLDialectTest.java
new file mode 100644
index 00000000000..0b93c37aa90
--- /dev/null
+++
b/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/sql/dialect/impl/CustomMySQLSQLDialectTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.sqlfederation.compiler.sql.dialect.impl;
+
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+class CustomMySQLSQLDialectTest {
+
+ @Test
+ void assertQuoteStringLiteralEscapesSingleQuoteForMySQL() {
+ StringBuilder actualBuilder = new StringBuilder();
+ CustomMySQLSQLDialect.DEFAULT.quoteStringLiteral(actualBuilder,
"utf8", "foo_value's");
+ assertThat(actualBuilder.toString(), is("'foo_value''s'"));
+ }
+}
diff --git
a/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/sql/dialect/impl/CustomPostgreSQLSQLDialectTest.java
b/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/sql/dialect/impl/CustomPostgreSQLSQLDialectTest.java
new file mode 100644
index 00000000000..56c072779c6
--- /dev/null
+++
b/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/sql/dialect/impl/CustomPostgreSQLSQLDialectTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.sqlfederation.compiler.sql.dialect.impl;
+
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+class CustomPostgreSQLSQLDialectTest {
+
+ @Test
+ void assertQuoteStringLiteral() {
+ StringBuilder actualBuilder = new StringBuilder();
+ CustomPostgreSQLSQLDialect.DEFAULT.quoteStringLiteral(actualBuilder,
"utf8", "foo_value's");
+ assertThat(actualBuilder.toString(), is("'foo_value''s'"));
+ }
+}