Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arbitrary SELECTs #6

Open
dleavitt opened this issue Sep 28, 2011 · 4 comments
Open

Arbitrary SELECTs #6

dleavitt opened this issue Sep 28, 2011 · 4 comments

Comments

@dleavitt
Copy link

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.

@ernie
Copy link
Owner

ernie commented Sep 29, 2011

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.

@gamov
Copy link

gamov commented Nov 11, 2011

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!

@masterkain
Copy link

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?

@krainboltgreene
Copy link

This would also be useful for things like hstore:

Person.values_of("data -> name")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants