-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diff: can use multiple columns to split chunks (#197)
* sync_diff_inspector: fix a misleading regex example in config.toml (#141) * update pkg about database (#142) * diff: add database name and table name router (#172) * simplify the if/else logic (#179) refactor to simplify the if/else logic * diff: can use multiple columns to split chunks (#130) * simplify the if/else logic (#191)
- Loading branch information
1 parent
170311c
commit 1a02077
Showing
16 changed files
with
1,317 additions
and
458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2018 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, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package dbutil | ||
|
||
import ( | ||
. "github.com/pingcap/check" | ||
) | ||
|
||
func (*testDBSuite) TestReplacePlaceholder(c *C) { | ||
testCases := []struct { | ||
originStr string | ||
args []string | ||
expectStr string | ||
}{ | ||
{ | ||
"a > ? AND a < ?", | ||
[]string{"1", "2"}, | ||
"a > '1' AND a < '2'", | ||
}, { | ||
"a = ? AND b = ?", | ||
[]string{"1", "2"}, | ||
"a = '1' AND b = '2'", | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
str := ReplacePlaceholder(testCase.originStr, testCase.args) | ||
c.Assert(str, Equals, testCase.expectStr) | ||
} | ||
|
||
} | ||
|
||
func (*testDBSuite) TestTableName(c *C) { | ||
testCases := []struct { | ||
schema string | ||
table string | ||
expectTableName string | ||
}{ | ||
{ | ||
"test", | ||
"testa", | ||
"`test`.`testa`", | ||
}, | ||
{ | ||
"test-1", | ||
"test-a", | ||
"`test-1`.`test-a`", | ||
}, | ||
{ | ||
"test", | ||
"t`esta", | ||
"`test`.`t``esta`", | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
tableName := TableName(testCase.schema, testCase.table) | ||
c.Assert(tableName, Equals, testCase.expectTableName) | ||
} | ||
} |
Oops, something went wrong.