Why is Rails is adding `OR 1=0` to queries using the where clause hash syntax with a range?

后端 未结 5 926
生来不讨喜
生来不讨喜 2020-12-17 10:04

The project that I\'m working on is using MySQL on RDS (mysql2 gem specifically).

When I use a hash of conditions including a range in a where statement

5条回答
  •  天命终不由人
    2020-12-17 10:41

    If you care about having control of the queries you generate and the full power of the SQL language and database features then I would suggest moving from ActiveRecord/Arel to Sequel.

    I can honestly say there are a lot more quirks and infuriating times ahead for you with ActiveRecord, especially when you move beyond simple crud like queries. When you start trying to query your data in anger, perhaps needing to join a few join tables here and there and realize you really do need join conditions or union all type queries.

    It is also significantly faster and more reliable in its query generation and result handling and much easier to compose the queries you want. It also has real documentation you can actually read unlike arel.

    I just wish I had discovered it much earlier rather than persisting with the rails default data access layer.

提交回复
热议问题