Hello again Jeremy, Seems like not many people are interested in taking part of this discussion unfortunately..
I understand there's other ways to achieve the same result as a `limit(0)` query, I'd already solved my problem in particular with the `where(false)` approach. Nevertheless I believe that my question still stands as it makes sense for such query to be valid. I can show you where exactly I faced this problem and how it was solved (https://github.com/rmosolgo/graphql-ruby/pull/892), but IMO the root of the issue should also be tackled. Thanks, João Serra On Monday, August 14, 2017 at 12:46:13 AM UTC+1, Jeremy Evans wrote: > > On Sunday, August 13, 2017 at 4:11:29 PM UTC-7, João Serra wrote: >> >> Hi there, >> >> I stumbled on a difference between ActiveRecord's behaviour and Sequel >> which I think make sense for Sequel to support too. >> >> If you're using ActiveRecord, it's possible to do a query with limit 0 >> (obviously yielding 0 results) but in Sequel it raises a "Sequel::Error >> Limits must be greater than or equal to 1". >> >> My question is, isn't it a perfectly valid SQL query? (I'm not familiar >> with all databases thus the question mark) >> > > It appears to work on SQLite and PostgreSQL, but I haven't tested all > other databases Sequel supports. I suppose there is no reason to limit the > use of 0, other than the fact that it is more likely to be an error than > desired behavior. If you don't want to return any rows, it makes more > sense to add a false condition (dataset.where(false) instead of > dataset.limit(0)). This is the first time someone has requested the > ability to use LIMIT 0 since the check was added 9 years ago. > > You can currently force a limit of 0 using a literal string: > dataset.limit(Sequel.lit('0')) > > One reason to keep this check is that Sequel currently converts a > non-literal string passed to Dataset#limit to an integer using #to_i. This > means that limit('foo') currently raises an error, but would start silently > returning no rows if this change was made. I suppose we could start having > different behavior for an integer argument compared to a string argument, > but then it becomes inconsistent. > > Anyway, I'd be interested in feedback from other Sequel users about their > thoughts on this. > > Thanks, > Jeremy > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
