<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<rewrite-assertions yaml-rule="yaml/sharding/sharding-rule.yaml">
    <rewrite-assertion id="insert_values_with_columns_with_id_for_parameters">
        <input sql="INSERT INTO t_account (account_id, amount, status) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE amount = VALUES(amount)" parameters="100, 1000, OK" />
        <output sql="INSERT INTO t_account_0 (account_id, amount, status) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE amount = VALUES(amount)" parameters="100, 1000, OK" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_values_with_columns_with_id_for_literals" db-type="MySQL">
        <input sql="INSERT INTO t_account (account_id, amount, status) VALUES (100, 1000, 'OK') ON DUPLICATE KEY UPDATE amount = VALUES(amount)" />
        <output sql="INSERT INTO t_account_0 (account_id, amount, status) VALUES (100, 1000, 'OK') ON DUPLICATE KEY UPDATE amount = VALUES(amount)" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_values_with_columns_without_id_for_parameters">
        <input sql="INSERT INTO t_account (amount, status) VALUES (?, ?)" parameters="1000, OK" />
        <output sql="INSERT INTO t_account_1 (amount, status, account_id) VALUES (?, ?, ?)" parameters="1000, OK, 1" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_values_with_columns_without_id_for_literals" db-type="MySQL">
        <input sql="INSERT INTO t_account (amount, status) VALUES (1000, 'OK')" />
        <output sql="INSERT INTO t_account_1 (amount, status, account_id) VALUES (1000, 'OK', 1)" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_values_without_columns_with_id_for_parameters">
        <input sql="INSERT INTO t_account VALUES (?, ?, ?)" parameters="100, 1000, OK" />
        <output sql="INSERT INTO t_account_0 VALUES (?, ?, ?)" parameters="100, 1000, OK" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_values_without_columns_with_id_for_literals" db-type="MySQL">
        <input sql="INSERT INTO t_account VALUES (100, 1000, 'OK')" />
        <output sql="INSERT INTO t_account_0 VALUES (100, 1000, 'OK')" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_values_without_columns_without_id_for_parameters">
        <input sql="INSERT INTO t_account VALUES (?, ?)" parameters="1000, OK" />
        <output sql="INSERT INTO t_account_1(amount, status, account_id) VALUES (?, ?, ?)" parameters="1000, OK, 1" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_values_without_columns_without_id_for_literals" db-type="MySQL">
        <input sql="INSERT INTO t_account VALUES (1000, 'OK')" />
        <output sql="INSERT INTO t_account_1(amount, status, account_id) VALUES (1000, 'OK', 1)" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_multiple_values_with_columns_with_id_for_parameters">
        <input sql="INSERT INTO t_account (account_id, amount, status) VALUES (100, 0, 'OK'), (?, ?, ?), (102, 2000, 'OK'), (?, ?, ?), (?, ?, ?), (105, 5000, 'OK')" parameters="101, 1000, OK, 103, 3000, OK, 104, 4000, OK" />
        <output sql="INSERT INTO t_account_0 (account_id, amount, status) VALUES (100, 0, 'OK'), (102, 2000, 'OK'), (?, ?, ?)" parameters="104, 4000, OK" />
        <output sql="INSERT INTO t_account_1 (account_id, amount, status) VALUES (?, ?, ?), (?, ?, ?), (105, 5000, 'OK')" parameters="101, 1000, OK, 103, 3000, OK" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_multiple_values_with_columns_with_id_for_literals">
        <input sql="INSERT INTO t_account (account_id, amount, status) VALUES (100, 0, 'OK'), (101, 1000, 'OK'), (102, 2000, 'OK'), (103, 3000, 'OK'), (104, 4000, 'OK'), (105, 5000, 'OK')" />
        <output sql="INSERT INTO t_account_0 (account_id, amount, status) VALUES (100, 0, 'OK'), (102, 2000, 'OK'), (104, 4000, 'OK')" />
        <output sql="INSERT INTO t_account_1 (account_id, amount, status) VALUES (101, 1000, 'OK'), (103, 3000, 'OK'), (105, 5000, 'OK')" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_multiple_values_with_columns_without_id_for_parameters">
        <input sql="INSERT INTO t_account (amount, status) VALUES (?, ?), (1000, 'OK')" parameters="1000, OK" />
        <output sql="INSERT INTO t_account_1 (amount, status, account_id) VALUES (?, ?, ?), (1000, 'OK', 1)" parameters="1000, OK, 1" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_multiple_values_with_columns_without_id_for_literals">
        <input sql="INSERT INTO t_account (amount, status) VALUES (1000, 'OK'), (1000, 'OK')" />
        <output sql="INSERT INTO t_account_1 (amount, status, account_id) VALUES (1000, 'OK', 1), (1000, 'OK', 1)" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_multiple_values_without_columns_with_id_for_parameters" db-type="MySQL">
        <input sql="INSERT INTO t_account VALUES (?, ?, ?), (101, 1000, 'OK')" parameters="100, 0, OK" />
        <output sql="INSERT INTO t_account_0 VALUES (?, ?, ?)" parameters="100, 0, OK" />
        <output sql="INSERT INTO t_account_1 VALUES (101, 1000, 'OK')" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_multiple_values_without_columns_with_id_for_literals" db-type="MySQL">
        <input sql="INSERT INTO t_account VALUES (100, 0, 'OK'), (101, 1000, 'OK')" />
        <output sql="INSERT INTO t_account_0 VALUES (100, 0, 'OK')" />
        <output sql="INSERT INTO t_account_1 VALUES (101, 1000, 'OK')" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_multiple_values_without_columns_without_id_for_parameters" db-type="MySQL">
        <input sql="INSERT INTO t_account VALUES (?, ?), (1000, 'OK')" parameters="1000, OK" />
        <output sql="INSERT INTO t_account_1(amount, status, account_id) VALUES (?, ?, ?), (1000, 'OK', 1)" parameters="1000, OK, 1" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_multiple_values_without_columns_without_id_for_literals" db-type="MySQL">
        <input sql="INSERT INTO t_account VALUES (1000, 'OK'), (1000, 'OK')" />
        <output sql="INSERT INTO t_account_1(amount, status, account_id) VALUES (1000, 'OK', 1), (1000, 'OK', 1)" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_set_with_columns_with_id_for_parameters" db-type="MySQL">
        <input sql="INSERT INTO t_account SET account_id = ?, amount = ?, status = ?" parameters="100, 1000, OK" />
        <output sql="INSERT INTO t_account_0 SET account_id = ?, amount = ?, status = ?" parameters="100, 1000, OK" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_set_with_columns_with_id_for_literals" db-type="MySQL">
        <input sql="INSERT INTO t_account SET account_id = 100, amount = 1000, status = 'OK'" />
        <output sql="INSERT INTO t_account_0 SET account_id = 100, amount = 1000, status = 'OK'" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_set_with_columns_without_id_for_parameters" db-type="MySQL">
        <input sql="INSERT INTO t_account SET amount = ?, status = ?" parameters="1000, OK" />
        <output sql="INSERT INTO t_account_1 SET amount = ?, status = ?, account_id = ?" parameters="1000, OK, 1" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_set_with_columns_without_id_for_literals" db-type="MySQL">
        <input sql="INSERT INTO t_account SET amount = 1000, status = 'OK'" />
        <output sql="INSERT INTO t_account_1 SET amount = 1000, status = 'OK', account_id = 1" />
    </rewrite-assertion>
    
    <rewrite-assertion id="insert_into_with_columns_without_id_for_parameters" db-type="MySQL">
        <input sql="INSERT INTO t_account SET amount = ?, status = ?" parameters="1000, OK" />
        <output sql="INSERT INTO t_account_1 SET amount = ?, status = ?, account_id = ?" parameters="1000, OK, 1" />
    </rewrite-assertion>
</rewrite-assertions>
