Hi all,
we want to provide a plain SQL console for admins of our application. Since we are using then tenant logic with a row level access filter to separate several entities between different user groups, the SQL should only operate on data that belongs to the admin of a user group.
That would mean something like this:
SELECT b.title FROM BOOKS b WHERE b.tenantId = :currentTenantId
Since the admins won’t enter their own tenantId to their queries we would like to add that before execution of their SQL. Since the dataManager won’t work with native SQL, my question would be if there is some service method that converts the SQL back to jpql so the filtering can be added by the dataManager?
Or would it be more feasible to use a library for SQL parsing like JSqlParser and get the tables from the SQL, check if they have a tenantId column, enhance the WHERE statement and build a final SQL from that?
Somewhere on the road from the dataManager to the database, JMix needs to add the restrictions to the JPQL or SQL as well, no? How is that done (in broad terms, I can debug the transformation but it is a bit creepy in that part of the code haha
Thanks a lot in advance!