moqui / moqui-framework

Use Moqui Framework to build enterprise applications based on Java. It includes tools for databases (relational, graph, document), local and web services, web and other UI with screens and forms, security, file/resource access, scripts, templates, l10n, caching, logging, search, rules, workflow, multi-instance, and integration.
http://www.moqui.org
Other
279 stars 199 forks source link

Need to support custom SQL #599

Open daiagou opened 1 year ago

daiagou commented 1 year ago

For example, I just mentioned a login optimization issue:https://github.com/moqui/moqui-framework/issues/598 The SQL I suggest:DELETE from user_login_key where USER_ID=? and THRU_DATE < ?; update table set amount=amount-1 where amount>?; select max(xxx) from table; and so on. But currently, Moqui does not support it.

acetousk commented 1 year ago

Your first example, it looked like this was tried at some point see this. I bet that with a bit more effort, this problem could be resolved instead of supporting custom SQL for a whole bunch of different databases.

If you want to code a SQL function call in a screen or service, you can use the sqlFind method in EntityFacade.java line 87 for finding an entity list (just like an entity-find).

For a more general SQL implementation, it might be good to have one that can be accessed programatically. This would allow for something like what you suggested. One problem with this is that Moqui supports multiple databases that have different SQL syntax. Moqui currently handles that by making simple CRUD queries easy which is the 90% of the database query use-cases.