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

Discrepancy in docs vs typescript types for locks #11178

Closed
2 of 7 tasks
michaelfarrell76 opened this issue Jul 10, 2019 · 8 comments
Closed
2 of 7 tasks

Discrepancy in docs vs typescript types for locks #11178

michaelfarrell76 opened this issue Jul 10, 2019 · 8 comments
Labels
status: wip For issues and PRs. Applied when the PR is not ready yet / when work to close the issue has started. type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.

Comments

@michaelfarrell76
Copy link

What are you doing?

I am attempting to lock a table when I perform a find query. The documentation seems to have a discrepancy in how these locks can be created, however the typescript types do not sync up

The following will produce a type error:

await MigrationLock.findAll({
  where: { isLocked: false },
  transaction,
  lock: true,
});

See below for all of the typescript warnings that also seem to be valid code as stated in the docs here and here

Screen Shot 2019-07-10 at 1 02 16 PM
Screen Shot 2019-07-10 at 1 02 37 PM
Screen Shot 2019-07-10 at 1 02 41 PM

To Reproduce
Steps to reproduce the behavior:

  1. Define model MigrationLock using typescript
  2. Try to provide lock: true in findAll
  3. See typescript error

What do you expect to happen?

I want to be able to have a type-safe find lock on a table

What is actually happening?

Typescript keeps yelling at me

Environment

Dialect:

  • mysql
  • postgres
  • sqlite
  • mssql
  • any

Dialect library version: 10.4
Database version: 10.4
Sequelize version: 5.9.4
Node Version: v10.15.0
OS: OSX Mojave 10.14.5

If TypeScript related: TypeScript version: XXX
Tested with latest release:

  • No
  • Yes, specify that version: 3.5.2
@papb papb added type: docs For issues and PRs. Things related to documentation, such as changes in the manuals / API reference. status: awaiting investigation type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense. labels Jul 24, 2019
@aecorredor
Copy link
Contributor

aecorredor commented Sep 14, 2019

Having the same issue here.

When I do something like:

const user = await models.sequelize.transaction(async t => {
  const contest = await models.Contest.findByPk(id, {
    transaction: t,
    lock: true,
  });

  // ...rest of the code, returns user at the end
});

I get Type 'true' is not assignable to type 'LOCK | { level: LOCK; of: typeof Model; } | undefined'.

@aecorredor
Copy link
Contributor

Any updates?

@papb
Copy link
Member

papb commented Oct 27, 2019

@aecorredor No, would you like to try to make a PR?

@aecorredor
Copy link
Contributor

@papb sure thing, I'll give it a shot, just wanted to make sure that it was indeed a bug in the types and not me doing something wrong.

@papb
Copy link
Member

papb commented Oct 28, 2019

@aecorredor Ah, ok! Indeed looks like a bug. Thank you very much. I will fix the issue label

@papb papb added status: understood For issues. Applied when the issue is understood / reproducible. and removed status: awaiting investigation type: docs For issues and PRs. Things related to documentation, such as changes in the manuals / API reference. labels Oct 28, 2019
@aecorredor
Copy link
Contributor

@papb PR for this issue is here: #11620. Let me know if everything looks good or if I need to do something else. It's my first time making a PR for this repo, so I might have missed something.

@papb papb added status: wip For issues and PRs. Applied when the PR is not ready yet / when work to close the issue has started. and removed status: understood For issues. Applied when the issue is understood / reproducible. labels Oct 28, 2019
@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2021

This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

@github-actions github-actions bot added the stale label Nov 9, 2021
@WikiRik WikiRik removed the stale label Nov 15, 2021
@ephys
Copy link
Member

ephys commented Apr 16, 2022

Looks like this was fixed by #11620

@ephys ephys closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: wip For issues and PRs. Applied when the PR is not ready yet / when work to close the issue has started. type: typescript For issues and PRs. Things that involve typescript, such as typings and intellisense.
Projects
None yet
Development

No branches or pull requests

5 participants