SixiS / jquery_query_builder-rails

The jQuery Query Builder Rule Evaluator and JavaScript library + Dependencies ready for the Rails Asset Pipeline
MIT License
30 stars 17 forks source link

Feature request - SQL queries for active record #8

Open montulli opened 5 years ago

montulli commented 5 years ago

Big feature request I know. :)

If this library could build active record scopes based on the filter params it would be god like!

Also of interest, generic SQL queries. (That might be easier than using active record)

SixiS commented 5 years ago

Hi @montulli Thanks for the request! This has sort of already been built.

https://querybuilder.js.org/plugins.html#sql-support

The jQuery plugin can generate the sql for you - you could then send that through to your server.

Pretty scary getting sql from a frontend... It should be possible to use something like https://github.com/cowboyd/therubyracer to run it server-side tho.

montulli commented 5 years ago

I can't trust SQL coming from the front end and running JavaScript on the server side seems inefficient. I have a working implementation now of SQL generation in RUBY in my branch that is here: https://github.com/jetinsight/jquery_query_builder-rails

If you are interested, I can make a pull request so you can review it. I'm happy to make changes to suit your requirements.