3 ms·
Sure - I know how it works and that it's useful. Still - it breaks the no-surprise rule for me... You could always have stacking functions with both .where and
by viraptor 16y ago
Sure - I know how it works and that it's useful. Still - it breaks the no-surprise rule for me...
You could always have stacking functions with both .where and .combine_where, so that:
User.where(:name => "david").limit(20).where("age > 29")
gives you (with second where starting new level of query):
SELECT * FROM (SELECT * FROM user WHERE name = 'david' LIMIT 20) WHERE age > 29
and this (combine_where folding into the same expression):
User.where(:name => "david").limit(20).combine_where("age > 29")
gives you:
SELECT * FROM user WHERE name = 'david' AND age > 29 LIMIT 20
Just like you don't expect `map()[range].map()` or whatever the equivalent in Ruby is, to combine the map calls and move the range to the end.