Using eval in code is not safe and may lead to security
risks, especially given that query itself is supplied by a user.
This refactors the code making is presumably safe
and prone to code injections, which are possible with eval.
Story: 2011539
Task: 52866
Change-Id: If629023052aa2c067c419bba10837f77bcc3e59c
Signed-off-by: Dmitriy Rabotyagov <dmitriy@adria-cloud.com>