You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/03/13 14:46:03 UTC
(shardingsphere) branch master updated: An assertion supporting CREATE DATABASE (#38414)
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 17b70381b7a An assertion supporting CREATE DATABASE (#38414)
17b70381b7a is described below
commit 17b70381b7aced6ecd77b525264805cb405dbc9a
Author: cxy <xi...@qq.com>
AuthorDate: Fri Mar 13 22:45:57 2026 +0800
An assertion supporting CREATE DATABASE (#38414)
---
.../ddl/standard/StandardDDLStatementAssert.java | 5 ++
.../type/CreateDatabaseStatementAssert.java | 41 ++++++++++++++
.../main/resources/case/ddl/create-database.xml | 66 +++++++++++-----------
3 files changed, 79 insertions(+), 33 deletions(-)
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/StandardDDLStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/StandardDDLStatementAssert.java
index f2428287f28..762e053146b 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/StandardDDLStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/StandardDDLStatementAssert.java
@@ -28,6 +28,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.Mo
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.TruncateStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.catalog.AlterCatalogStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.AlterDatabaseStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.CreateDatabaseStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.AlterIndexStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.CreateIndexStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.index.DropIndexStatement;
@@ -52,6 +53,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropFil
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.oracle.database.OracleAlterPluggableDatabaseStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.standard.type.AlterCatalogStatementAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.standard.type.CreateDatabaseStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.standard.type.AlterIndexStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.standard.type.AlterSynonymStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.standard.type.AlterTableStatementAssert;
@@ -89,6 +91,7 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.s
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.TruncateStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.catalog.AlterCatalogStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.database.AlterDatabaseStatementTestCase;
+import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.database.CreateDatabaseStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.AlterIndexStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.CreateIndexStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.index.DropIndexStatementTestCase;
@@ -185,6 +188,8 @@ public final class StandardDDLStatementAssert {
CancelAlterTableStatementAssert.assertIs(assertContext, (CancelAlterTableStatement) actual, (CancelAlterTableStatementTestCase) expected);
} else if (actual instanceof DropEncryptKeyStatement) {
DropEncryptKeyStatementAssert.assertIs(assertContext, (DropEncryptKeyStatement) actual, (DropEncryptKeyStatementTestCase) expected);
+ } else if (actual instanceof CreateDatabaseStatement) {
+ CreateDatabaseStatementAssert.assertIs(assertContext, (CreateDatabaseStatement) actual, (CreateDatabaseStatementTestCase) expected);
}
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/type/CreateDatabaseStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/type/CreateDatabaseStatementAssert.java
new file mode 100644
index 00000000000..0ab0ce23768
--- /dev/null
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/standard/type/CreateDatabaseStatementAssert.java
@@ -0,0 +1,41 @@
+/*
+ * 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.test.it.sql.parser.internal.asserts.statement.ddl.standard.type;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.CreateDatabaseStatement;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.standard.database.CreateDatabaseStatementTestCase;
+
+/**
+ * Create database statement assert.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class CreateDatabaseStatementAssert {
+
+ /**
+ * Assert create database statement is correct with expected parser result.
+ *
+ * @param assertContext assert context
+ * @param actual actual create database statement
+ * @param expected expected create database statement test case
+ */
+ public static void assertIs(final SQLCaseAssertContext assertContext, final CreateDatabaseStatement actual, final CreateDatabaseStatementTestCase expected) {
+ }
+}
diff --git a/test/it/parser/src/main/resources/case/ddl/create-database.xml b/test/it/parser/src/main/resources/case/ddl/create-database.xml
index 7604122307e..f8e159f1300 100644
--- a/test/it/parser/src/main/resources/case/ddl/create-database.xml
+++ b/test/it/parser/src/main/resources/case/ddl/create-database.xml
@@ -26,69 +26,69 @@
<create-database sql-case-id="create_database_oracle1" />
<create-database sql-case-id="create_database_oracle2" />
<create-database sql-case-id="create_database_basic" />
- <create-schema sql-case-id="create_schema_basic" />
+ <create-database sql-case-id="create_schema_basic" />
<create-database sql-case-id="create_database_if_not_exists" />
- <create-schema sql-case-id="create_schema_if_not_exists" />
+ <create-database sql-case-id="create_schema_if_not_exists" />
<create-database sql-case-id="create_remote_database_basic" />
- <create-schema sql-case-id="create_remote_schema_basic" />
+ <create-database sql-case-id="create_remote_schema_basic" />
<create-database sql-case-id="create_remote_database_if_not_exists" />
- <create-schema sql-case-id="create_remote_schema_if_not_exists" />
+ <create-database sql-case-id="create_remote_schema_if_not_exists" />
<create-database sql-case-id="create_database_with_comment" />
- <create-schema sql-case-id="create_schema_with_comment" />
+ <create-database sql-case-id="create_schema_with_comment" />
<create-database sql-case-id="create_database_if_not_exists_with_comment" />
- <create-schema sql-case-id="create_schema_if_not_exists_with_comment" />
+ <create-database sql-case-id="create_schema_if_not_exists_with_comment" />
<create-database sql-case-id="create_database_with_location_hive" />
- <create-schema sql-case-id="create_schema_with_location" />
+ <create-database sql-case-id="create_schema_with_location" />
<create-database sql-case-id="create_database_if_not_exists_with_location" />
- <create-schema sql-case-id="create_schema_if_not_exists_with_location" />
+ <create-database sql-case-id="create_schema_if_not_exists_with_location" />
<create-database sql-case-id="create_database_with_managed_location" />
- <create-schema sql-case-id="create_schema_with_managed_location" />
+ <create-database sql-case-id="create_schema_with_managed_location" />
<create-database sql-case-id="create_database_if_not_exists_with_managed_location" />
- <create-schema sql-case-id="create_schema_if_not_exists_with_managed_location" />
+ <create-database sql-case-id="create_schema_if_not_exists_with_managed_location" />
<create-database sql-case-id="create_database_with_properties" />
- <create-schema sql-case-id="create_schema_with_properties" />
+ <create-database sql-case-id="create_schema_with_properties" />
<create-database sql-case-id="create_database_with_single_property" />
- <create-schema sql-case-id="create_schema_with_single_property" />
+ <create-database sql-case-id="create_schema_with_single_property" />
<create-database sql-case-id="create_database_if_not_exists_with_properties" />
- <create-schema sql-case-id="create_schema_if_not_exists_with_properties" />
+ <create-database sql-case-id="create_schema_if_not_exists_with_properties" />
<create-database sql-case-id="create_database_with_comment_location" />
- <create-schema sql-case-id="create_schema_with_comment_location" />
+ <create-database sql-case-id="create_schema_with_comment_location" />
<create-database sql-case-id="create_database_with_comment_managedlocation" />
- <create-schema sql-case-id="create_schema_with_comment_managedlocation" />
+ <create-database sql-case-id="create_schema_with_comment_managedlocation" />
<create-database sql-case-id="create_database_with_comment_properties" />
- <create-schema sql-case-id="create_schema_with_comment_properties" />
+ <create-database sql-case-id="create_schema_with_comment_properties" />
<create-database sql-case-id="create_database_with_location_managedlocation" />
- <create-schema sql-case-id="create_schema_with_location_managedlocation" />
+ <create-database sql-case-id="create_schema_with_location_managedlocation" />
<create-database sql-case-id="create_database_with_location_properties" />
- <create-schema sql-case-id="create_schema_with_location_properties" />
+ <create-database sql-case-id="create_schema_with_location_properties" />
<create-database sql-case-id="create_database_with_managedlocation_properties" />
- <create-schema sql-case-id="create_schema_with_managedlocation_properties" />
+ <create-database sql-case-id="create_schema_with_managedlocation_properties" />
<create-database sql-case-id="create_database_with_location_managedlocation_properties" />
- <create-schema sql-case-id="create_schema_with_location_managedlocation_properties" />
+ <create-database sql-case-id="create_schema_with_location_managedlocation_properties" />
<create-database sql-case-id="create_database_with_comment_location_managedlocation" />
- <create-schema sql-case-id="create_schema_with_comment_location_managedlocation" />
+ <create-database sql-case-id="create_schema_with_comment_location_managedlocation" />
<create-database sql-case-id="create_database_with_comment_managedlocation_properties" />
- <create-schema sql-case-id="create_schema_with_comment_managedlocation_properties" />
+ <create-database sql-case-id="create_schema_with_comment_managedlocation_properties" />
<create-database sql-case-id="create_database_with_all_options" />
- <create-schema sql-case-id="create_schema_with_all_options" />
+ <create-database sql-case-id="create_schema_with_all_options" />
<create-database sql-case-id="create_remote_database_with_comment_managedlocation" />
- <create-schema sql-case-id="create_remote_schema_with_comment_managedlocation" />
+ <create-database sql-case-id="create_remote_schema_with_comment_managedlocation" />
<create-database sql-case-id="create_remote_database_with_location_managedlocation" />
- <create-schema sql-case-id="create_remote_schema_with_location_managedlocation" />
+ <create-database sql-case-id="create_remote_schema_with_location_managedlocation" />
<create-database sql-case-id="create_remote_database_with_managedlocation_properties" />
- <create-schema sql-case-id="create_remote_schema_with_managedlocation_properties" />
+ <create-database sql-case-id="create_remote_schema_with_managedlocation_properties" />
<create-database sql-case-id="create_remote_database_with_comment_location" />
- <create-schema sql-case-id="create_remote_schema_with_comment_location" />
+ <create-database sql-case-id="create_remote_schema_with_comment_location" />
<create-database sql-case-id="create_remote_database_with_comment_properties" />
- <create-schema sql-case-id="create_remote_schema_with_comment_properties" />
+ <create-database sql-case-id="create_remote_schema_with_comment_properties" />
<create-database sql-case-id="create_remote_database_with_location_properties" />
- <create-schema sql-case-id="create_remote_schema_with_location_properties" />
+ <create-database sql-case-id="create_remote_schema_with_location_properties" />
<create-database sql-case-id="create_remote_database_with_comment_location_managedlocation" />
- <create-schema sql-case-id="create_remote_schema_with_comment_location_managedlocation" />
+ <create-database sql-case-id="create_remote_schema_with_comment_location_managedlocation" />
<create-database sql-case-id="create_remote_database_with_comment_managedlocation_properties" />
- <create-schema sql-case-id="create_remote_schema_with_comment_managedlocation_properties" />
+ <create-database sql-case-id="create_remote_schema_with_comment_managedlocation_properties" />
<create-database sql-case-id="create_remote_database_with_location_managedlocation_properties" />
- <create-schema sql-case-id="create_remote_schema_with_location_managedlocation_properties" />
+ <create-database sql-case-id="create_remote_schema_with_location_managedlocation_properties" />
<create-database sql-case-id="create_remote_database_with_all_options" />
- <create-schema sql-case-id="create_remote_schema_with_all_options" />
+ <create-database sql-case-id="create_remote_schema_with_all_options" />
</sql-parser-test-cases>