// Copyright 2022 PingCAP, Inc. // // Licensed 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. package core import ( "fmt" "math/rand" "sync" "testing" "time" "github.com/pingcap/tidb/parser" "github.com/pingcap/tidb/parser/ast" "github.com/stretchr/testify/require" ) func TestParameterize(t *testing.T) { cases := []struct { sql string paramSQL string params []interface{} }{ { "select * from t where a<10", "SELECT * FROM `t` WHERE `a`40", "SELECT * FROM `t` WHERE `a`?", []interface{}{int64(10), int64(20), int64(30), int64(40)}, }, { "select * from t where a='a' and b='bbbbbbbbbbbbbbbbbbbbbbbb'", "SELECT * FROM `t` WHERE `a`=? AND `b`=?", []interface{}{"a", "bbbbbbbbbbbbbbbbbbbbbbbb"}, }, { "select 1, 2, 3 from t where a<10", "SELECT 1,2,3 FROM `t` WHERE `a`