Natively Check parameter requirement in Query in Orientdb

52 Views Asked by At

Is it possible to natively check whether a SQL query requires a parameter(positional or named) to be injected??? I can do it using 'regex' but was searching for some native odb API way.

Thanx

Note : Have removed the updated comment, felt it was unethical

1

There are 1 best solutions below

1
Luigi Dell'Aquila On BEST ANSWER

The official answer is NO, here is no exposed API for this right now.

All you can do right now (v 2.2 and 3.0) is parse the SQL statement as follows:

String statement = ....; // the SQL query
InputStream is = new ByteArrayInputStream(statement.getBytes());
OrientSql osql = new OrientSql(is);
OStatement result = osql.parse();

and check its content to find instances of OInputParameter.

PLEASE CONSIDER THAT IT'S NOT INTENDED AS A PUBLIC API, SO IT MAY CHANGE IN NEXT RELEASES.