0

I'm just trying out some stuff and I found something interesting, when I try to pass a string argument to the limit method I get an error.

Here is an example :

User.where('id > 10000').limit('ALL')

The error thrown is :

ArgumentError: invalid value for Integer(): "ALL"

This works of course :

User.where('id > 10000').limit(5)

But according to postgresql docs, should be possible to pass the ALL as a limit : http://www.postgresql.org/docs/8.1/static/queries-limit.html

And works on simple query from pgadmin that I tried :

select id from users limit ALL

Is there a workaround for rails with this error?

1 Answer 1

2

LIMIT ALL is the same as omitting the LIMIT clause.

I think the postgres docs are pretty clear here. Just remove the limit. i.e.

User.where('id > 10000')
Sign up to request clarification or add additional context in comments.

5 Comments

thanks for your response, I know I can remove the all clause, I'm just wondering if there is a way to make it work with rails/AR
make what work? The limit all syntax does not provide functionality that is not available otherwise.
it is available otherwise, we can all see the obvious. I had a specific question, and looking for specific answer. If there is no answer or you might not know it, that's ok because there is always option of removing the limit I think we all get that.
Well the answer is there is no way to make active record generate a 'LIMIT ALL' query. (because it's database specific and provides no additional functionality)
Ok that's seems to be the case for now, I'll accept in a little while

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.