valium icon indicating copy to clipboard operation
valium copied to clipboard

Arbitrary SELECTs

Open dleavitt opened this issue 13 years ago • 4 comments

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.

dleavitt avatar Sep 28 '11 23:09 dleavitt

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.

ernie avatar Sep 29 '11 21:09 ernie

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!

gamov avatar Nov 11 '11 06:11 gamov

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?

masterkain avatar Jan 27 '12 19:01 masterkain

This would also be useful for things like hstore:

Person.values_of("data -> name")

krainboltgreene avatar May 20 '13 09:05 krainboltgreene