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

fix(typings): `comparator` arg of `Sequelize.where` #11843

Merged
merged 3 commits into from Jan 25, 2020

Conversation

@EduardMcfly
Copy link
Contributor

EduardMcfly commented Jan 18, 2020

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

In the types of the where function, in the comparator parameter a symbol is added as type, this solves problems when using the constant Op the function where

Example of the problem i had:

import { Op } from 'sequelize';

Sequelize.where(
 Sequelize.fn('LOWER', Sequelize.col('email')),
 Op.like, // error Argument of type 'unique symbol' is not assignable to parameter of type 'string'.ts
 Sequelize.fn('LOWER', email + '%'),
)

Closes #11241

comparator parameter a symbol is added as type
@codecov

This comment has been minimized.

Copy link

codecov bot commented Jan 18, 2020

Codecov Report

Merging #11843 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11843      +/-   ##
==========================================
+ Coverage   96.26%   96.27%   +<.01%     
==========================================
  Files          94       94              
  Lines        9191     9203      +12     
==========================================
+ Hits         8848     8860      +12     
  Misses        343      343
Impacted Files Coverage Δ
lib/associations/belongs-to-many.js 98.07% <0%> (ø) ⬆️
lib/dialects/mariadb/data-types.js 100% <0%> (ø) ⬆️
lib/model.js 96.54% <0%> (ø) ⬆️
lib/dialects/abstract/query-generator.js 97.02% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fbd19d9...93822f5. Read the comment docs.

@papb

This comment has been minimized.

Copy link
Member

papb commented Jan 18, 2020

Hello! I see you are a first-time contributor, thank you for taking the time to help Sequelize! I hope to see more PRs from you in the future!

Copy link
Member

papb left a comment

Please add at least one test to make sure your implementation works as intended and to prevent regressions in the future.

Testing the TypeScript typings consists simply on checking if some code can be compiled. In other words, a typings test is just some TS code that should compile. What it does when executed is irrelevant, the test is simply to compile it without errors, as can be seen in our CI configuration (using npm run test-typings) here and here. Since it's just a compilation, getting no output from it means that it passed. Getting a compilation error is a failure. Note that if you directly throw an error from your typings test code, the test will still pass because throwing an error is something that compiles just fine.

For good examples on how to write typescript typings, check the following PRs: #11368 #11378 #11520

Let me know if you need further help!

@papb papb changed the title fix(tipings): In the where function, in the comparator parameter a symbol is added as type fix(typings): `comparator` arg of `Sequelize.where` Jan 18, 2020
@EduardMcfly EduardMcfly force-pushed the EduardMcfly:master branch from f6c6678 to c5f0338 Jan 20, 2020
a symbol and a null value are added
@EduardMcfly EduardMcfly force-pushed the EduardMcfly:master branch from c5f0338 to 1d7f300 Jan 20, 2020
@EduardMcfly

This comment has been minimized.

Copy link
Contributor Author

EduardMcfly commented Jan 20, 2020

Good day

Already perform the tipings test and everything is working correctly, also add other types to the logic arg of Sequelize.where

@papb

This comment has been minimized.

Copy link
Member

papb commented Jan 21, 2020

Hello, you still haven't added a test.

@EduardMcfly

This comment has been minimized.

Copy link
Contributor Author

EduardMcfly commented Jan 22, 2020

Hi Pedro, I already added some tests In the file types\test\where.ts

@papb
papb approved these changes Jan 23, 2020
@papb

This comment has been minimized.

Copy link
Member

papb commented Jan 23, 2020

@andres112013 Thank you very much! Before merging I would like to wait for a review by @SimonSchick as well

@sushantdhiman sushantdhiman merged commit 1a53892 into sequelize:master Jan 25, 2020
4 checks passed
4 checks passed
codecov/patch Coverage not affected when comparing fbd19d9...93822f5
Details
codecov/project 96.27% (+<.01%) compared to fbd19d9
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.