This is an automated email from the ASF dual-hosted git repository.
chengzhang 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 f4afcc30b33 Add more sql bind test case for delete and update
statement (#34150)
f4afcc30b33 is described below
commit f4afcc30b3375faed386a01b37facbfaa46c96f8
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Wed Dec 25 18:47:23 2024 +0800
Add more sql bind test case for delete and update statement (#34150)
---
.../binder/src/test/resources/cases/dml/delete.xml | 61 +++++++++++++++++
.../binder/src/test/resources/cases/dml/update.xml | 78 ++++++++++++++++++++++
.../binder/src/test/resources/sqls/dml/delete.xml | 21 ++++++
.../binder/src/test/resources/sqls/dml/update.xml | 21 ++++++
4 files changed, 181 insertions(+)
diff --git a/test/it/binder/src/test/resources/cases/dml/delete.xml
b/test/it/binder/src/test/resources/cases/dml/delete.xml
new file mode 100644
index 00000000000..0c3cfe4f348
--- /dev/null
+++ b/test/it/binder/src/test/resources/cases/dml/delete.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<sql-parser-test-cases>
+ <delete sql-case-id="delete_order_by">
+ <table name="t_order" start-index="12" stop-index="18">
+ <table-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ </table-bound>
+ </table>
+ <where start-index="20" stop-index="37">
+ <expr>
+ <binary-operation-expression start-index="26" stop-index="37">
+ <left>
+ <column name="order_id" start-index="26"
stop-index="33">
+ <column-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="order_id"
start-delimiter="`" end-delimiter="`" />
+ </column-bound>
+ </column>
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression value="1" start-index="37"
stop-index="37" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ <order-by>
+ <column-item name="user_id" start-index="48" stop-index="54">
+ <column-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="user_id" start-delimiter="`"
end-delimiter="`" />
+ </column-bound>
+ </column-item>
+ </order-by>
+ <limit start-index="56" stop-index="62">
+ <row-count value="1" start-index="62" stop-index="62" />
+ </limit>
+ </delete>
+</sql-parser-test-cases>
diff --git a/test/it/binder/src/test/resources/cases/dml/update.xml
b/test/it/binder/src/test/resources/cases/dml/update.xml
new file mode 100644
index 00000000000..d6b9141cae6
--- /dev/null
+++ b/test/it/binder/src/test/resources/cases/dml/update.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<sql-parser-test-cases>
+ <update sql-case-id="update_order_by">
+ <table start-index="7" stop-index="13">
+ <simple-table name="t_order" start-index="7" stop-index="13">
+ <table-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ </table-bound>
+ </simple-table>
+ </table>
+ <set start-index="15" stop-index="29">
+ <assignment start-index="19" stop-index="29">
+ <column name="user_id" start-index="19" stop-index="25">
+ <column-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="user_id" start-delimiter="`"
end-delimiter="`" />
+ </column-bound>
+ </column>
+ <assignment-value>
+ <literal-expression value="1" start-index="29"
stop-index="29" />
+ </assignment-value>
+ </assignment>
+ </set>
+ <where start-index="31" stop-index="48">
+ <expr>
+ <binary-operation-expression start-index="37" stop-index="48">
+ <left>
+ <column name="order_id" start-index="37"
stop-index="44">
+ <column-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="order_id"
start-delimiter="`" end-delimiter="`" />
+ </column-bound>
+ </column>
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression value="1" start-index="48"
stop-index="48" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ <order-by>
+ <column-item name="user_id" start-index="59" stop-index="65">
+ <column-bound>
+ <original-database name="foo_db_1" />
+ <original-schema name="foo_db_1" />
+ <original-table name="t_order" />
+ <original-column name="user_id" start-delimiter="`"
end-delimiter="`" />
+ </column-bound>
+ </column-item>
+ </order-by>
+ <limit start-index="67" stop-index="73">
+ <row-count value="1" start-index="73" stop-index="73" />
+ </limit>
+ </update>
+</sql-parser-test-cases>
diff --git a/test/it/binder/src/test/resources/sqls/dml/delete.xml
b/test/it/binder/src/test/resources/sqls/dml/delete.xml
new file mode 100644
index 00000000000..f43f5868102
--- /dev/null
+++ b/test/it/binder/src/test/resources/sqls/dml/delete.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<sql-cases>
+ <sql-case id="delete_order_by" value="DELETE FROM t_order WHERE order_id =
1 ORDER BY user_id LIMIT 1" db-types="MySQL"/>
+</sql-cases>
diff --git a/test/it/binder/src/test/resources/sqls/dml/update.xml
b/test/it/binder/src/test/resources/sqls/dml/update.xml
new file mode 100644
index 00000000000..3bbd5d91711
--- /dev/null
+++ b/test/it/binder/src/test/resources/sqls/dml/update.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<sql-cases>
+ <sql-case id="update_order_by" value="UPDATE t_order SET user_id = 1 WHERE
order_id = 1 ORDER BY user_id LIMIT 1" db-types="MySQL"/>
+</sql-cases>