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 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
Copy link

@codecov 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
Copy link
Member

@papb 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 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
@papb papb added status: awaiting response type: typescript labels Jan 18, 2020
a symbol and a null value are added
@EduardMcfly
Copy link
Contributor Author

@EduardMcfly 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
Copy link
Member

@papb papb commented Jan 21, 2020

Hello, you still haven't added a test.

@EduardMcfly
Copy link
Contributor Author

@EduardMcfly 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
Copy link
Member

@papb papb commented Jan 23, 2020

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

@papb papb requested a review from SimonSchick Jan 23, 2020
@papb papb added status: awaiting maintainer and removed status: awaiting response labels Jan 23, 2020
@sushantdhiman sushantdhiman merged commit 1a53892 into sequelize:master Jan 25, 2020
4 checks passed
@sushantdhiman sushantdhiman removed the status: awaiting maintainer label Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants