<?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/encrypt/query-with-plain.yaml">
    <rewrite-assertion id="select_plain_for_parameters">
        <input sql="SELECT a.account_id, a.password, a.amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.account_id = ? AND a.password = ? AND a.amount = ? AND a.status = ?" parameters="1, aaa, 1000, OK" />
        <output sql="SELECT a.account_id, a.plain_password AS password, a.plain_amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.account_id = ? AND a.plain_password = ? AND a.plain_amount = ? AND a.status = ?" parameters="1, aaa, 1000, OK" />
    </rewrite-assertion>
    
    <rewrite-assertion id="select_plain_for_literals">
        <input sql="SELECT a.account_id, a.password, a.amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.account_id = 1 AND a.password = 'aaa' AND a.amount = 1000 AND a.status = 'OK'" />
        <output sql="SELECT a.account_id, a.plain_password AS password, a.plain_amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.account_id = 1 AND a.plain_password = 'aaa' AND a.plain_amount = 1000 AND a.status = 'OK'" />
    </rewrite-assertion>
    
    <rewrite-assertion id="select_with_unqualified_shorthand">
        <input sql="SELECT * FROM t_account_bak" />
        <output sql="SELECT account_id, cipher_certificate_number AS certificate_number, plain_password AS password, plain_amount AS amount, status FROM t_account_bak" />
    </rewrite-assertion>
    
    <rewrite-assertion id="select_with_qualified_shorthand">
        <input sql="SELECT a.* FROM t_account_bak a" />
        <output sql="SELECT a.account_id, a.cipher_certificate_number AS certificate_number, a.plain_password AS password, a.plain_amount AS amount, a.status FROM t_account_bak a" />
    </rewrite-assertion>
    
    <rewrite-assertion id="select_with_mix_qualified_shorthand_and_other_projection">
        <input sql="SELECT a.*, account_id, 1+1 FROM t_account_bak a" />
        <output sql="SELECT a.account_id, a.cipher_certificate_number AS certificate_number, a.plain_password AS password, a.plain_amount AS amount, a.status, account_id, 1+1 FROM t_account_bak a" />
    </rewrite-assertion>
</rewrite-assertions>
