Faveod / arel-extensions

Extending Arel
MIT License
142 stars 24 forks source link

in: accept arrays that contain ranges #20

Closed akimd closed 4 years ago

akimd commented 4 years ago

One would like to be able to run queries such as

User.where(User[:id].in [1..10, 20, 30..40, 50, nil])

and leave the desugaring to ArelX.

I'm sorry, this is only a draft: it is quite a task to be able to run purely syntactic tests of ArelX: I don't plan to install dbms, I just want to run the dummy tests such as test/visitors/test_to_sql.rb, but I saw no easy means to do it. In fact I can't even run the code, there might be stupid syntactic errors. sorry about that.

This feature (on dates) would have been valuable in the project I work on. I was lucky enough that ActiveRecord does support it.