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
add validation in .offset()
#2908
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, but PR is missing tests. Also maybe knex.raw / query builder should be allowed. At least it should be tested what that method does in case of those.
https://github.com/tgriesser/knex/blob/master/test/unit/query/builder.js#L6457 I believe this test case covers my PR now. Is there any scenarios that test case cannot cover? |
Actually that case looks like that it has been designed so that passing null actually clears the offset, thus it shouldn't show warning. Also in case of warning it should check that warning is actually emitted. It can be done by using custom loggers in test. Also I would prefer throwing an error instead of warning. |
@HurSungYun @elhigu Actually, passing null to reset sounds like a valid case, no? |
We discussed something like this #2897 It concluded that everything like this should be valid, so I believe this one also should be valid case |
I believe this test cases are enough for checking whether warning message is emitted. |
Now this prevents using knex.raw / query builder as a parameter for offset, which has been working previously. |
My bad. I misunderstood your comment. I'll revise it to work properly. |
The code of
I tried some tests in Node 8,
So, it does not break using knex.raw as a parameter if the evaluated result of knex.raw can be parsed to int and if that cannot be parse to int, it is invalid input anyway. I would like to suggest two options for
OR
I understand all this should be backward compatible, but I think it's weird that there's no validation code in contrast with |
when will this changes be releaed? |
@NeoyeElf I fixed something but i don't know when this PR is merged |
test/unit/query/builder.js
Outdated
oracledb: new Oracledb_Client( | ||
Object.assign({ client: 'oracledb' }, customLoggerConfig) | ||
), | ||
// sqlite3: new SQLite3_Client( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there was no sqlite3 tests using offset a year ago.
maybe someone have missed test code so I did the same thing.
still some test does not include sqlite3, but it may be fixed in another PR.
anyway I un-commented it.
Sorry for the delay in reviewing. This can be merged after couple of minor comments are addressed. |
what is the default value of offset() |
@rjkhan No offset, I believe. |
I believe
value
in.offset(value)
must be integer like.limit(value)
However, there is no warning message for this.