valium
valium copied to clipboard
Arbitrary SELECTs
I don't know if this is feasible or in scope, but it would be pretty cool if one could use arbitrary select criteria.
So like:
Shoe.value_of "DISTINCT category"
or
Shoe.select('DISTINCT category AS category').value_of :category
Instead of Shoe.select('DISTINCT category AS category').map(&:category)
Unless there is already a good way to do this, with or without valium.
I like this idea (the first one, especially) but my only immediate thought is that it could be tricky to know what type to cast the value to for things that aren't as simple as a distinct
-- and I'd want it to work across the board. Might require a hint of some kind.
Exactly what I was thinking. I noticed that valium rewrite the select() instruction. As DISTINCT is such a common case, adding a unique_value_of to valium would be great!
I'd like to select and perform a concat(..fields..) AS sort
(for a late ORDER BY sort
) in my query to help with a bottleneck I'm experiencing by having to sort by multiple columns.
Any ideas how to accomplish that using Valium?
This would also be useful for things like hstore:
Person.values_of("data -> name")