I use this generator for Go (https://github.com/Masterminds/squirrel) and I have to create an SQL where parser.
Suppose I have user’s inputs like these:
- Bar.Alpha = 7
- Foo.Bar.X = ‘hello’
- Foo.Bar.Beta > 21 AND Alpha.Bar != ‘hello’
- Alice.IsActive AND Bob.LastHash = ‘ab5534b’
- Alice.Name ~ ‘A.’ OR Bob.LastName !~ 'Bill.’
- Field1 = “foo” AND Field2 != 7 OR Field3 > 11.7
There might be lots of AND / OR in user’s queries. How to dynamically generate them? Thanks.