SQL Case

Target

The code for SQL case is in module sharding-sql-test.There are two targets for this module:

  1. Test the wildcard replacement by unit test.
  2. Share the SQL resource in resources folder.
<sql-cases>
    <sql-case id="select_constant_without_table" value="SELECT 1 as a" />
    <sql-case id="select_with_same_table_name_and_alias" value="SELECT t_order.* FROM t_order t_order WHERE user_id = ? AND order_id = ?" />
    <sql-case id="select_with_same_table_name_and_alias_column_with_owner" value="SELECT t_order.order_id,t_order.user_id,status FROM t_order t_order WHERE t_order.user_id = ? AND order_id = ?" db-types="MySQL,H2"/>
</sql-cases>

Developer setup the SQL for assertion and database type during on the configuration file. And these SQLs could share in different test engine, that’s why we extract the sharding-sql-test as a stand alone module.

Process

Following is the data handling process in SQL case :

Test Engine