0
0
0x6B72616B656E2013-07-25 08:10:11
Java
0x6B72616B656E, 2013-07-25 08:10:11

Parsing sql expression from a string

The project had a task to implement the ability to filter data in the API. The filter is a string. An example of the string "name LIKE 'Lesha' OR name LIKE 'Sasha' AND (age > 40 OR age < 30)"

This expression must be parsed and, using the structure already obtained
1., replace "age" "name" with the actual field names.
2. check the expression for correctness 3. create a new expression that will be passed along with the query to the
database, while excluding sql injections (algorithms) Tell me useful libraries for parsing expressions from a string that can be customized to my needs.



Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
catlion, 2013-07-25
@0x6B72616B656E

zql.sourceforge.net/
jsqlparser.sourceforge.net/
sqljep.sourceforge.net/
www.playframework.com/documentation/2.0/ScalaAnorm
ANTLR3 + grammar from here or any other parser generator .

J
jj_killer, 2013-07-25
@jj_killer

You can go this way: www.complang.org/ragel/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question