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

Passing null as limit() value stops the chain #182

Closed
ricardograca opened this Issue Feb 18, 2014 · 3 comments

Comments

Projects
None yet
3 participants
@ricardograca
Collaborator

ricardograca commented Feb 18, 2014

I have a portion of code that sets the limit conditionally to either 1 or no limit at all. However, if I pass null as the value to the .limit() method, the chain is interrupted since that method doesn't return this in case the value in null. However, according to the PostgreSQL docs if the value of LIMIT evaluates to NULL it is treated as LIMIT ALL i.e. no limit, so the behavior of Knex is not entirely consistent with the expected behavior from the database server.

I know I can pass the string ALL as value to work around this, but it would be nice to have a bit of clarification as to what would happen when passing null as value in case this is by design, which seems to be the case. It seems to me that passing null is a way of returning the current limit value, but I fail to see how that is useful and how it can be used with a query if it stops the chain.

@bendrucker bendrucker added the bug label Feb 18, 2014

@bendrucker

This comment has been minimized.

Collaborator

bendrucker commented Feb 18, 2014

I'm marking this as a bug—the convention for returning query parts when the input is empty is probably more confusing than it is useful. @tgriesser is there something that depends on it?

@tgriesser tgriesser closed this in 6470af8 Feb 18, 2014

@tgriesser

This comment has been minimized.

Owner

tgriesser commented Feb 18, 2014

Fixed and 0.5.7

@ricardograca

This comment has been minimized.

Collaborator

ricardograca commented Feb 18, 2014

Damn that was fast! :D

2014-02-18 15:05 GMT+00:00 Tim Griesser notifications@github.com:

Fixed and 0.5.7


Reply to this email directly or view it on GitHubhttps://github.com//issues/182#issuecomment-35392735
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment