Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for #1216, move the UpdateStatementParserTest relative test cases to IntegrateParsingTest. #1272

Merged
merged 5 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ private void assertUpdateStatementWitOr(final DMLStatement updateStatement) {

@Test
public void parseWithSpecialSyntax() {
parseWithSpecialSyntax(DatabaseType.MySQL, "UPDATE `TABLE_XXX` SET `field1`=1 WHERE `field1`=1");
parseWithSpecialSyntax(DatabaseType.Oracle, "UPDATE /*+ index(field1) */ ONLY TABLE_XXX SET field1=1 WHERE field1=1 RETURN * LOG ERRORS INTO TABLE_LOG");
parseWithSpecialSyntax(DatabaseType.Oracle, "UPDATE /*+ index(field1) */ ONLY TABLE_XXX SET field1=1 WHERE field1=1 RETURNING *");
parseWithSpecialSyntax(DatabaseType.Oracle, "UPDATE /*+ index(field1) */ ONLY TABLE_XXX SET field1=1 WHERE field1=1 LOG ERRORS INTO TABLE_LOG");
Expand Down
20 changes: 20 additions & 0 deletions sharding-core/src/test/resources/parser/update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,24 @@
</and-condition>
</or-condition>
</parser-result>

<parser-result sql-case-id="update_with_special_character" parameters="'update', 1, 1">
<tables>
<table name="t_order" />
</tables>
<tokens>
<table-token begin-position="7" original-literals="`t_order`" />
</tokens>
<or-condition>
<and-condition>
<condition column-name="order_id" table-name="t_order" operator="EQUAL">
<value index="1" literal="1" type="int" />
</condition>
<condition column-name="user_id" table-name="t_order" operator="EQUAL">
<value index="2" literal="1" type="int" />
</condition>
</and-condition>
</or-condition>
</parser-result>

</parser-result-sets>
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,30 @@
<assertion parameters="update:String, 1000:int, 10:int" expected-data-file="update.xml" />
</dml-test-case>

<dml-test-case sql-case-id="update_with_special_character">
<assertion parameters="update:String, 1000:int, 10:int" expected-data-file="update.xml" />
</dml-test-case>

<dml-test-case sql-case-id="delete_with_sharding_value">
<assertion parameters="1000:int, 10:int, init:String" expected-data-file="delete_with_sharding_value.xml" />
</dml-test-case>

<dml-test-case sql-case-id="delete_without_sharding_value">
<assertion parameters="init:String" expected-data-file="delete_without_sharding_value.xml" />
</dml-test-case>

<dml-test-case sql-case-id="delete_with_special_character_without_sharding_value">
<assertion expected-data-file="delete_with_special_character_without_sharding_value.xml" />
</dml-test-case>

<dml-test-case sql-case-id="delete_with_special_comments_without_sharding_value">
<assertion expected-data-file="delete_with_special_comments_without_sharding_value.xml" />
</dml-test-case>

<dml-test-case sql-case-id="delete_with_special_comments_return_without_sharding_value">
<assertion expected-data-file="delete_with_special_comments_return_without_sharding_value.xml" />
</dml-test-case>

<dml-test-case sql-case-id="delete_with_special_comments_returning_without_sharding_value">
<assertion expected-data-file="delete_with_special_comments_returning_without_sharding_value.xml" />
</dml-test-case>
Expand Down
1 change: 1 addition & 0 deletions sharding-sql-test/src/main/resources/sql/dml/update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<sql-case id="update_equal_with_geography" value="UPDATE t_place SET start_time = ?, status = 0, start_point = ST_GeographyFromText('SRID=4326;POINT('||?||' '||?||')'), rule = ?::jsonb, discount_type = ?, order_type = ? WHERE user_new_id = ? AND guid = ?" db-types="PostgreSQL" />
<sql-case id="update_without_condition" value="UPDATE t_order o SET o.status = 'finished'" db-types="MySQL,H2" />
<sql-case id="update_with_extra_keywords" value="UPDATE LOW_PRIORITY IGNORE t_order SET status = ? WHERE order_id = ? AND user_id = ?" db-types="MySQL" />
<sql-case id="update_with_special_character" value="UPDATE `t_order` SET `status` = ? WHERE `order_id` = ? AND user_id = ?" db-types="MySQL" />
</sql-cases>