未验证 提交 701c08f1 编写于 作者: Z Zonglei Dong 提交者: GitHub

Add SQLServer output clause test case. (#7654)

* fixes collection empty condition.

* add test case for SQLServer output clause without output table column.

* add test case for SQLServer output clause without output table.

* add test case for SQLServer output clause column shorthand.

* fixes checkstyle problem.
上级 9491e6f9
......@@ -46,13 +46,13 @@ public final class OutputClauseAssert {
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final OutputSegment actual, final ExpectedOutputClause expected) {
assertNotNull(assertContext.getText("Output clause should exist."), expected);
if (null != actual.getOutputColumns()) {
if (!actual.getOutputColumns().isEmpty()) {
assertOutputColumnsSegment(assertContext, actual, expected);
}
if (null != actual.getTableName()) {
assertOutputTableSegment(assertContext, actual, expected);
}
if (null != actual.getTableColumns()) {
if (!actual.getTableColumns().isEmpty()) {
assertOutputTableColumnSegment(assertContext, actual, expected);
}
SQLSegmentAssert.assertIs(assertContext, actual, expected);
......
......@@ -1453,7 +1453,7 @@
</value>
</values>
</insert>
<insert sql-case-id="insert_with_default_values">
<table name="t_order" start-index="12" stop-index="18" />
<columns start-index="20" stop-index="46">
......@@ -1462,12 +1462,12 @@
<column name="status" start-index="40" stop-index="45" />
</columns>
</insert>
<insert sql-case-id="insert_without_columns_with_default_values">
<table name="t_order" start-index="12" stop-index="18" />
<columns start-index="19" stop-index="19" />
</insert>
<insert sql-case-id="insert_with_top">
<table name="t_order" start-index="15" stop-index="21" />
<columns start-index="23" stop-index="41">
......@@ -1486,7 +1486,7 @@
</projections>
</select>
</insert>
<insert sql-case-id="insert_with_top_percent">
<table name="t_order" start-index="23" stop-index="29" />
<columns start-index="31" stop-index="49">
......@@ -1505,7 +1505,7 @@
</projections>
</select>
</insert>
<insert sql-case-id="insert_with_output_clause" parameters="1, 1">
<table name="t_order" start-index="12" stop-index="18" />
<columns start-index="20" stop-index="38">
......@@ -1540,4 +1540,86 @@
</value>
</values>
</insert>
<insert sql-case-id="insert_with_output_clause_without_output_table_columns" parameters="1, 1">
<table name="t_order" start-index="12" stop-index="18" />
<columns start-index="20" stop-index="38">
<column name="order_id" start-index="21" stop-index="28" />
<column name="user_id" start-index="31" stop-index="37" />
</columns>
<output start-index="40" stop-index="98">
<output-columns start-index="47" stop-index="81">
<column-projection name="order_id" start-index="47" stop-index="63">
<owner name="INSERTED" start-index="47" stop-index="54"/>
</column-projection>
<column-projection name="user_id" start-index="66" stop-index="81">
<owner name="INSERTED" start-index="66" stop-index="73"/>
</column-projection>
</output-columns>
<output-table name="@MyTableVar" start-index="88" stop-index="98"/>
</output>
<values>
<value>
<assignment-value>
<parameter-marker-expression value="0" start-index="108" stop-index="108" />
<literal-expression value="1" start-index="108" stop-index="108" />
</assignment-value>
<assignment-value>
<parameter-marker-expression value="1" start-index="111" stop-index="111" />
<literal-expression value="1" start-index="111" stop-index="111" />
</assignment-value>
</value>
</values>
</insert>
<insert sql-case-id="insert_with_output_clause_without_output_table" parameters="1, 1">
<table name="t_order" start-index="12" stop-index="18" />
<columns start-index="20" stop-index="38">
<column name="order_id" start-index="21" stop-index="28" />
<column name="user_id" start-index="31" stop-index="37" />
</columns>
<output start-index="40" stop-index="81">
<output-columns start-index="47" stop-index="81">
<column-projection name="order_id" start-index="47" stop-index="63">
<owner name="INSERTED" start-index="47" stop-index="54"/>
</column-projection>
<column-projection name="user_id" start-index="66" stop-index="81">
<owner name="INSERTED" start-index="66" stop-index="73"/>
</column-projection>
</output-columns>
</output>
<values>
<value>
<assignment-value>
<parameter-marker-expression value="0" start-index="91" stop-index="91" />
<literal-expression value="1" start-index="91" stop-index="91" />
</assignment-value>
<assignment-value>
<parameter-marker-expression value="1" start-index="94" stop-index="94" />
<literal-expression value="1" start-index="94" stop-index="94" />
</assignment-value>
</value>
</values>
</insert>
<insert sql-case-id="insert_with_output_clause_column_shorthand" parameters="1, 1">
<table name="t_order" start-index="12" stop-index="18" />
<columns start-index="20" stop-index="38">
<column name="order_id" start-index="21" stop-index="28" />
<column name="user_id" start-index="31" stop-index="37" />
</columns>
<output start-index="40" stop-index="56"/>
<values>
<value>
<assignment-value>
<parameter-marker-expression value="0" start-index="66" stop-index="66" />
<literal-expression value="1" start-index="66" stop-index="66" />
</assignment-value>
<assignment-value>
<parameter-marker-expression value="1" start-index="69" stop-index="69" />
<literal-expression value="1" start-index="69" stop-index="69" />
</assignment-value>
</value>
</values>
</insert>
</sql-parser-test-cases>
......@@ -73,4 +73,7 @@
<sql-case id="insert_with_top_percent" value="INSERT TOP(10) PERCENT t_order (order_id, user_id) SELECT order_id, user_id FROM t_order" db-types="SQLServer" />
<sql-case id="insert_with_columnname_uuid" value="insert into t_order (id,uuid) values (?, ?)" db-types="PostgreSQL" />
<sql-case id="insert_with_output_clause" value="INSERT INTO t_order (order_id, user_id) OUTPUT INSERTED.order_id, INSERTED.user_id INTO @MyTableVar (temp_order_id, temp_user_id) VALUES (?, ?)" db-types="SQLServer" />
<sql-case id="insert_with_output_clause_without_output_table_columns" value="INSERT INTO t_order (order_id, user_id) OUTPUT INSERTED.order_id, INSERTED.user_id INTO @MyTableVar VALUES (?, ?)" db-types="SQLServer" />
<sql-case id="insert_with_output_clause_without_output_table" value="INSERT INTO t_order (order_id, user_id) OUTPUT INSERTED.order_id, INSERTED.user_id VALUES (?, ?)" db-types="SQLServer" />
<sql-case id="insert_with_output_clause_column_shorthand" value="INSERT INTO t_order (order_id, user_id) OUTPUT INSERTED.* VALUES (?, ?)" db-types="SQLServer" />
</sql-cases>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册