Skip to content

Commit

Permalink
For #628: prepared update sql support :: grammars test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
haocao committed Apr 1, 2018
1 parent 699b06b commit 7d87737
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
19 changes: 19 additions & 0 deletions sharding-core/src/test/resources/parser/update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,23 @@
</condition>
</conditions>
</parser-result>

<!-- TODO add update :: support
<parser-result sql-case-id="assertUpdateWithGeoInPostgreSQL" parameters="'2017-06-07' 100 200 '{&quot;rule2&quot;:&quot;null2&quot;}' 3 5 7 200">
<tables>
<table name="t_place" />
</tables>
<tokens>
<table-token begin-position="7" original-literals="t_place" />
</tokens>
<conditions>
<condition column-name="user_new_id" table-name="t_place" operator="EQUAL">
<value index="6" literal="7" type="int" />
</condition>
<condition column-name="guid" table-name="t_place" operator="EQUAL">
<value index="7" literal="200" type="int"/>
</condition>
</conditions>
</parser-result>
-->
</parser-result-sets>
6 changes: 6 additions & 0 deletions sharding-core/src/test/resources/yaml/parser-rule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ shardingRule:
shardingColumns: user_id, order_id, item_id
algorithmClassName: io.shardingjdbc.core.api.algorithm.fixture.TestComplexKeysShardingAlgorithm
keyGeneratorColumnName: item_id
t_place:
actualDataNodes: db${0..1}.t_place
tableStrategy:
complex:
shardingColumns: user_new_id, guid
algorithmClassName: io.shardingjdbc.core.api.algorithm.fixture.TestComplexKeysShardingAlgorithm
bindingTables:
- t_order, t_order_item
defaultKeyGeneratorClass: io.shardingjdbc.core.keygen.fixture.IncrementKeyGenerator
3 changes: 2 additions & 1 deletion sharding-sql-test/src/main/resources/sql/dml/update.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<sql-cases>
<sql-case id="assertUpdateWithAlias" value="UPDATE t_order AS o SET o.status = %s WHERE o.order_id = %s AND o.user_id = %s" db-types="MySQL,H2"/>
<sql-case id="assertUpdateWithAlias" value="UPDATE t_order AS o SET o.status = %s WHERE o.order_id = %s AND o.user_id = %s" db-types="MySQL,H2" />
<sql-case id="assertUpdateWithoutAlias" value="UPDATE t_order SET status = %s WHERE order_id = %s AND user_id = %s" />
<sql-case id="assertUpdateWithGeoInPostgreSQL" value="UPDATE t_place SET start_time = %s, status = 0, start_point = ST_GeographyFromText('SRID=4326;POINT('||%s||' '||%s||')'), rule = %s::jsonb, discount_type = %s, order_type = %s WHERE user_new_id = %s AND guid = %s" db-types="PostgreSQL" />
</sql-cases>

0 comments on commit 7d87737

Please sign in to comment.