Ability to acquire a connection
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 734
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
Motivation
We can't force a set of SQL queries to be executed on the same database connection, unless by doing a transaction, which is not what I want.
Additionally, this implies that a database connection used for a set of SQL queries may be used concurrently by another process, because DbConn is simply a pool, which acquires a connection on each query.
This is very unfortunate because it makes it impossible to ensure the lock/unlock of tables properly, for example.
It is indeed possible to do it ourselves, but it is very cumbersome and should be part of this library. Plus, we can't replicate the exact implementation of DbConn (e.g. with metrics etc).
Proposed Solutions
Make an additional type for acquired connections (not pools), that could be constructed from a new acquire method on the DbConn type. This new type would implement the traits ConnectionTrait and why not TransactionTrait.
Additional Information
This issue is related to #1457, which was converted into a discussion here: https://github.com/SeaQL/sea-orm/discussions/1503, but nothing was done.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the DbConn/DatabaseConnection documentation and the ConnectionTrait and TransactionTrait definitions linked in the issue. Determine how an acquired connection should preserve one pool connection across multiple queries, then verify that the proposed type supports the required connection traits and table lock/unlock workflow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100