From e66d2c55ea90dc9c4d53134a189498ab2456a2fd Mon Sep 17 00:00:00 2001 From: haocao Date: Tue, 15 Aug 2017 10:17:13 +0800 Subject: [PATCH] Add func test cases for group by. --- .../rdb/common/util/SqlPlaceholderUtil.java | 4 +- .../integrate/assert/select_group_by.xml | 5 ++ .../tbl/expect/select/SelectIteratorSql_0.xml | 4 +- .../tbl/expect/select/SelectIteratorSql_1.xml | 4 +- .../tbl/expect/select/SelectIteratorSql_2.xml | 4 +- .../tbl/expect/select/SelectIteratorSql_3.xml | 4 +- .../expect/select/SelectNoShardingTable.xml | 80 +++++++++---------- .../select/SelectNotEqualsWithSingleTable.xml | 78 +++++++++--------- .../SelectPagingWithOffsetAndRowCountSql.xml | 4 +- .../select/SelectPagingWithRowCountSql.xml | 4 +- .../expect/select/SelectWithBindingTable.xml | 40 +++++----- .../SelectWithBindingTableAndConfigTable.xml | 40 +++++----- .../SelectPagingWithOffsetAndRowCountSql.xml | 4 - .../mysql/SelectPagingWithRowCountSql.xml | 4 - .../SelectPagingWithOffsetAndRowCountSql.xml | 4 +- .../oracle/SelectPagingWithRowCountSql.xml | 4 +- .../SelectPagingWithOffsetAndRowCountSql.xml | 4 +- .../postgresql/SelectPagingWithOffsetSql.xml | 4 +- .../SelectPagingWithRowCountSql.xml | 4 +- .../SelectPagingWithOffsetAndRowCountSql.xml | 4 +- .../sqlserver/SelectPagingWithRowCountSql.xml | 4 +- .../tbl/expect/select_group_by/SelectFunc.xml | 4 + .../integrate/dataset/tbl/init/tbl.xml | 80 +++++++++---------- .../resources/integrate/schema/table/tbl.sql | 20 ++--- .../test/resources/sql/select_group_by.xml | 1 + 25 files changed, 207 insertions(+), 205 deletions(-) delete mode 100644 sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/mysql/SelectPagingWithOffsetAndRowCountSql.xml delete mode 100644 sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/mysql/SelectPagingWithRowCountSql.xml create mode 100644 sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select_group_by/SelectFunc.xml diff --git a/sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/common/util/SqlPlaceholderUtil.java b/sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/common/util/SqlPlaceholderUtil.java index d21d6d68fb..2630c3090a 100644 --- a/sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/common/util/SqlPlaceholderUtil.java +++ b/sharding-jdbc-core/src/test/java/com/dangdang/ddframe/rdb/common/util/SqlPlaceholderUtil.java @@ -28,10 +28,10 @@ public final class SqlPlaceholderUtil { if (args.length == 0) { return str; } - return String.format(str, args); + return String.format(str, args).replace("%%", "%"); } public static String replacePreparedStatement(final String str) { - return str.replace("%s", Symbol.QUESTION.getLiterals()); + return str.replace("%s", Symbol.QUESTION.getLiterals()).replace("%%", "%"); } } diff --git a/sharding-jdbc-core/src/test/resources/integrate/assert/select_group_by.xml b/sharding-jdbc-core/src/test/resources/integrate/assert/select_group_by.xml index 458e05ffb9..b6c816f6bb 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/assert/select_group_by.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/assert/select_group_by.xml @@ -1,5 +1,10 @@ + + + + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_0.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_0.xml index cb4a61feb4..4cf74450dc 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_0.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_0.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_1.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_1.xml index 9023965eb3..0f05894bc5 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_1.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_1.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_2.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_2.xml index 3c62824f7c..120abc7c0e 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_2.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_2.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_3.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_3.xml index 647b1a2a51..ef249f550f 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_3.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectIteratorSql_3.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectNoShardingTable.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectNoShardingTable.xml index 61a3d0f405..41ac5d66ed 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectNoShardingTable.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectNoShardingTable.xml @@ -1,42 +1,42 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectNotEqualsWithSingleTable.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectNotEqualsWithSingleTable.xml index 546be75c6f..d8cd17e363 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectNotEqualsWithSingleTable.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectNotEqualsWithSingleTable.xml @@ -1,41 +1,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectPagingWithOffsetAndRowCountSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectPagingWithOffsetAndRowCountSql.xml index 2f1fbfad84..ca31427592 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectPagingWithOffsetAndRowCountSql.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectPagingWithOffsetAndRowCountSql.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectPagingWithRowCountSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectPagingWithRowCountSql.xml index be8abd3e13..9400df3fa3 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectPagingWithRowCountSql.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectPagingWithRowCountSql.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectWithBindingTable.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectWithBindingTable.xml index fc40aca771..779c946165 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectWithBindingTable.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectWithBindingTable.xml @@ -1,22 +1,22 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectWithBindingTableAndConfigTable.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectWithBindingTableAndConfigTable.xml index fc40aca771..779c946165 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectWithBindingTableAndConfigTable.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/SelectWithBindingTableAndConfigTable.xml @@ -1,22 +1,22 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/mysql/SelectPagingWithOffsetAndRowCountSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/mysql/SelectPagingWithOffsetAndRowCountSql.xml deleted file mode 100644 index 2f1fbfad84..0000000000 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/mysql/SelectPagingWithOffsetAndRowCountSql.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/mysql/SelectPagingWithRowCountSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/mysql/SelectPagingWithRowCountSql.xml deleted file mode 100644 index be8abd3e13..0000000000 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/mysql/SelectPagingWithRowCountSql.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/oracle/SelectPagingWithOffsetAndRowCountSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/oracle/SelectPagingWithOffsetAndRowCountSql.xml index 37b13d91d1..fbf4e39eae 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/oracle/SelectPagingWithOffsetAndRowCountSql.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/oracle/SelectPagingWithOffsetAndRowCountSql.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/oracle/SelectPagingWithRowCountSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/oracle/SelectPagingWithRowCountSql.xml index 409a0a719f..789553a84d 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/oracle/SelectPagingWithRowCountSql.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/oracle/SelectPagingWithRowCountSql.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithOffsetAndRowCountSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithOffsetAndRowCountSql.xml index 2f1fbfad84..ca31427592 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithOffsetAndRowCountSql.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithOffsetAndRowCountSql.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithOffsetSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithOffsetSql.xml index 878cb7a54c..c5b1347fd6 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithOffsetSql.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithOffsetSql.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithRowCountSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithRowCountSql.xml index be8abd3e13..9400df3fa3 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithRowCountSql.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/postgresql/SelectPagingWithRowCountSql.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/sqlserver/SelectPagingWithOffsetAndRowCountSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/sqlserver/SelectPagingWithOffsetAndRowCountSql.xml index ed65e998cd..b4cdc3797c 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/sqlserver/SelectPagingWithOffsetAndRowCountSql.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/sqlserver/SelectPagingWithOffsetAndRowCountSql.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/sqlserver/SelectPagingWithRowCountSql.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/sqlserver/SelectPagingWithRowCountSql.xml index 9c49e0971f..e92611c692 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/sqlserver/SelectPagingWithRowCountSql.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select/sqlserver/SelectPagingWithRowCountSql.xml @@ -1,4 +1,4 @@ - - + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select_group_by/SelectFunc.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select_group_by/SelectFunc.xml new file mode 100644 index 0000000000..616ef987a4 --- /dev/null +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/expect/select_group_by/SelectFunc.xml @@ -0,0 +1,4 @@ + + + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/init/tbl.xml b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/init/tbl.xml index d55e7cd975..140f795278 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/init/tbl.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/dataset/tbl/init/tbl.xml @@ -20,46 +20,46 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharding-jdbc-core/src/test/resources/integrate/schema/table/tbl.sql b/sharding-jdbc-core/src/test/resources/integrate/schema/table/tbl.sql index 0c946d283b..e108566f29 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/schema/table/tbl.sql +++ b/sharding-jdbc-core/src/test/resources/integrate/schema/table/tbl.sql @@ -8,14 +8,14 @@ CREATE TABLE t_order_6 (order_id INT NOT NULL, user_id INT NOT NULL, status VARC CREATE TABLE t_order_7 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id)); CREATE TABLE t_order_8 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id)); CREATE TABLE t_order_9 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id)); -CREATE TABLE t_order_item_0 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id)); -CREATE TABLE t_order_item_1 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id)); -CREATE TABLE t_order_item_2 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id)); -CREATE TABLE t_order_item_3 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id)); -CREATE TABLE t_order_item_4 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id)); -CREATE TABLE t_order_item_5 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id)); -CREATE TABLE t_order_item_6 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id)); -CREATE TABLE t_order_item_7 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id)); -CREATE TABLE t_order_item_8 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id)); -CREATE TABLE t_order_item_9 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (item_id)); +CREATE TABLE t_order_item_0 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, cdate DATE, PRIMARY KEY (item_id)); +CREATE TABLE t_order_item_1 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, cdate DATE, PRIMARY KEY (item_id)); +CREATE TABLE t_order_item_2 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, cdate DATE, PRIMARY KEY (item_id)); +CREATE TABLE t_order_item_3 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, cdate DATE, PRIMARY KEY (item_id)); +CREATE TABLE t_order_item_4 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, cdate DATE, PRIMARY KEY (item_id)); +CREATE TABLE t_order_item_5 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, cdate DATE, PRIMARY KEY (item_id)); +CREATE TABLE t_order_item_6 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, cdate DATE, PRIMARY KEY (item_id)); +CREATE TABLE t_order_item_7 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, cdate DATE, PRIMARY KEY (item_id)); +CREATE TABLE t_order_item_8 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, cdate DATE, PRIMARY KEY (item_id)); +CREATE TABLE t_order_item_9 (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, cdate DATE, PRIMARY KEY (item_id)); CREATE TABLE t_config (id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (id)); diff --git a/sharding-jdbc-core/src/test/resources/sql/select_group_by.xml b/sharding-jdbc-core/src/test/resources/sql/select_group_by.xml index 8d9a59e9da..34b86cb464 100644 --- a/sharding-jdbc-core/src/test/resources/sql/select_group_by.xml +++ b/sharding-jdbc-core/src/test/resources/sql/select_group_by.xml @@ -1,5 +1,6 @@ + -- GitLab