Skip to content

Commit

Permalink
FIX LIT.003 bug
Browse files Browse the repository at this point in the history
  remove fmt.Println debug output
  LIT.003 remove varchar, text check for primary key
  • Loading branch information
martianzhang committed Jun 8, 2020
1 parent d61e49c commit ee6cfd0
Show file tree
Hide file tree
Showing 2 changed files with 321 additions and 322 deletions.
3 changes: 1 addition & 2 deletions advisor/heuristic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,6 @@ func (q *Query4Audit) RuleMultiBytesWord() Rule {
func (q *Query4Audit) RuleInvisibleUnicode() Rule {
var rule = q.RuleOK()
for _, tk := range ast.Tokenizer(q.Query) {
fmt.Println(tk.Val, []byte(tk.Val))
// 多字节的肉眼不可见字符经过 Tokenizer 后被切成了单字节字符。
// strings.Contains 中的内容也肉眼不可见,需要使用 cat -A 查看代码
switch tk.Val {
Expand Down Expand Up @@ -1692,7 +1691,7 @@ func (q *Query4Audit) RuleUNIONLimit() Rule {
// RuleMultiValueAttribute LIT.003
func (q *Query4Audit) RuleMultiValueAttribute() Rule {
var rule = q.RuleOK()
re := regexp.MustCompile(`(?i)(id\s+varchar)|(id\s+text)|(id\s+regexp)`)
re := regexp.MustCompile(`(?i)(id\s+regexp)`)
if re.FindString(q.Query) != "" {
rule = HeuristicRules["LIT.003"]
if position := re.FindIndex([]byte(q.Query)); len(position) > 0 {
Expand Down
Loading

0 comments on commit ee6cfd0

Please sign in to comment.