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

Add unit tests for table comment #2098

merged 1 commit into from Jun 10, 2017


Copy link

@rizip1 rizip1 commented Jun 3, 2017

I created tests to add table comment. These are for postgresql, mysql and oracle as it seems to me that .comment() function is not supported for sqlite.
I test setting the comment and setting it back to empty string. I assume that many users will expect that .comment(null) or simply .comment() will work the same as .comment('') I also made tests for these cases. However .comment(null) and .comment() does not work that way in mysql so these tests are only for postgresql and oracle.

expect(tableSql[0].sql).to.equal('comment on table "users" is \'\'');

it('test set empty comment using null', function() {

This comment has been minimized.


elhigu Jun 9, 2017

I wouldn't consider setting comment to be empty string by setting it to null or undefined as a intended behaviour. So better to not add test for that functionality, since better test would be throwing an error because of invalid parameter.

Copy link

@elhigu elhigu left a comment

Thanks for tests! They look fine, except that none of the dialects should have tests that .comment with undefined / null / falsy param sets empty string comment. Invalid parameters should throw an error (any parameter that is not string).

So please delete those tests setting comments with non-string arguments and I can merge this.

@rizip1 rizip1 force-pushed the rizip1:add-table-comment-tests branch from 72e0ef8 to 97cef1d Jun 10, 2017
Copy link
Contributor Author

@rizip1 rizip1 commented Jun 10, 2017

Ok I deleted those non-string args tests and rebased.

* Tests for setting comment on table for postgresql, mysql and oracle

* No tests for sqlite as it does not seem to support comments

* No tests for mssql as it can not be tested simply using sql comparison
@rizip1 rizip1 force-pushed the rizip1:add-table-comment-tests branch from 97cef1d to 5ecef24 Jun 10, 2017
elhigu approved these changes Jun 10, 2017
@elhigu elhigu merged commit e63fe22 into knex:master Jun 10, 2017
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants