Skip to content

Conversation

@sudarshan12s
Copy link

@sudarshan12s sudarshan12s commented Oct 17, 2023

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description Of Change

The issue is raised here

  • Enabled skipLocked, forShare, lockOuterJoinFailure, lock properties for Oracle dialect.
  • Oracle does not have shared locks on individual table rows, FOR UPDATE is what i found closest to
    forShare dialect support .
  • FOR UPDATE cant be used in sql's along with these :
    • ORDER BY
    • FETCH NEXT 1 ROWS ( creates a inline view, ...)

It results in error
ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.

We can instead generate a subquery like this to avoid error , but it's not equivalent and is not correct all the time and might cause issues.
SELECT "id", "username", "awesome", "createdAt", "updatedAt" FROM "users" "user" WHERE rowid in (select rowid from "users" "user" where "user"."username" = 'jan' ORDER BY "user"."id" OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY) FOR UPDATE;

instead of

SELECT "id", "username", "awesome", "createdAt", "updatedAt" FROM "users" "user" WHERE "user"."username" = 'jan' ORDER BY "user"."id" OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY FOR UPDATE;

Modified tests to use different model API's just to simulate the locking functionality .
-- findOrCreate is replaced with findAll and create
-- findByPK instead of findByOne

Todos

* - enable lock support. For shared locks use FOR UPDATE
- modify tests accordingly

* - For oracle dialect avoid for update and FETCH next in same query

* - alignment changes . added comments.

* - add skip lock for update

* - minor changes

* - newline corrections

* - correct wording

* - space change

* - modify test fixing failure
Copy link
Member

@WikiRik WikiRik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I'll merge all three open oracle PRs together once they've all been approved.

@hjamil-24 can you review this one as well?

@WikiRik WikiRik changed the title feat(oracle): support lock feature (#1) feat(oracle): add support for lock Nov 3, 2023
@WikiRik WikiRik merged commit b284d37 into sequelize:v6 Nov 3, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2023

🎉 This PR is included in version 6.34.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants