question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rethink/rewrite rule 942130 with re2 support

See original GitHub issue

Motivation

Allow porters to have more options for using CRS in additional engines.

Proposed solution

The rule 942130 (SQL Tautology) matches using these regexes:

[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?=[\s'\"`()]*?(?:\b\1\b)
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?<=>[\s'\"`()]*?(?:\b\1\b)
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?like[\s'\"`()]*?(?:\b\1\b)
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?rlike[\s'\"`()]*?(?:\b\1\b)
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?sounds\s+like[\s'\"`()]*?(?:\b\1\b)
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?regexp[\s'\"`()]*?(?:\b\1\b)
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?!=[\s'\"`()]*?(?!\b\1\b)[\d\w]+
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?<=[\s'\"`()]*?(?!\b\1\b)[\d\w]+
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?>=[\s'\"`()]*?(?!\b\1\b)[\d\w]+
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?<>[\s'\"`()]*?(?!\b\1\b)[\d\w]+
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?<[\s'\"`()]*?(?!\b\1\b)[\d\w]+
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?>[\s'\"`()]*?(?!\b\1\b)[\d\w]+
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?\^[\s'\"`()]*?(?!\b\1\b)[\d\w]+
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?is\s+not[\s'\"`()]*?(?!\b\1\b)[\d\w]+
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?not\s+like[\s'\"`()]*?(?!\b\1\b)[\d\w]+
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?not\s+regexp[\s'\"`()]*?(?!\b\1\b)[\d\w]+
  • The usage of \1 is not compatible with re2, but we can probably change it for a named group like this:
[\s'\"`()]*?\b([\d\w]+)\b[\s'\"`()]*?=[\s'\"`()]*?(?:\b\1\b)

to

[\s'\"`()]*?\b(?P<one>[\d\w]+)\b[\s'\"`()]*?=[\s'\"`()]*?(?:\b(?P=one)\b)
  • still we need to think if there is an alternative for the “before text not matching” (?!\b that breaks the compatibility

Alternatives

Additional context

Tests are really simple for this rule in particular, I wonder if there is additional information on how this rule was crafted.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
fzipicommented, Feb 22, 2022

I like the macro expansion. Gives us more flexibility. We need to check if this works 🤔

0reactions
fzipicommented, Apr 4, 2022

Fixed by #2425

Read more comments on GitHub >

github_iconTop Results From Across the Web

2019
$29.95T | £24.00 cloth 978-1-942130-15-4. 288 pp. | 6 x 9. April. Bob Dylan's reception of the 2016 Nobel Prize for Literature has...
Read more >
2022 BUDGET PROPOSAL MAYOR JOHN HAMILTON
The department continues to support the Mayor's investment in ... Category 2 – Supplies request is $2,360 and represents no change over the ......
Read more >
Sin título - Agencia Literaria Carmen Balcells
Life-long learning opportunities will support their ability to adapt to change. The only certainty about the future is change. Higher education.
Read more >
googlelist.counts - Massachusetts Institute of Technology
the 23135932950 1 of 13151960974 2 and 12997686891 3 to 12137015015 4 a ... 76 also 616841255 77 now 611404229 78 help 611100561...
Read more >
GAM Star Fund p.l.c.
Collective Investment in Transferable Securities) Regulations, ... investors to potentially make a rapid re-allocation to equities in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found