149 Commits

Author SHA1 Message Date
Chris Tsang
bb5dead0c8 Docs 2023-01-12 13:55:39 +08:00
Chris Tsang
0787035a42 Docs 2023-01-12 13:51:43 +08:00
Billy Chan
cbd7a8d1c9
Cleanup the use of vec![] (#1367)
* Public methods accept any IntoIterator as argument

* refactoring
2023-01-11 14:17:06 +08:00
Chris Tsang
ed7be8a29b Improve error message 2023-01-10 15:35:56 +08:00
Chris Tsang
4210526ec1
Merge pull request #1311 from SeaQL/select-into-tuple
Select into tuple
2023-01-10 15:20:14 +08:00
Chris Tsang
d14e4a2160 Fix again 2023-01-09 15:20:01 +08:00
Chris Tsang
f0634c2451 Well clippy 2023-01-09 14:26:11 +08:00
Chris Tsang
a11c57d337 Introduce ColIdx 2023-01-09 14:02:23 +08:00
Billy Chan
e246d3faaf
Cont. Upgrade to SeaQuery 0.28.0 (#1366)
* Upgrade to SeaQuery 0.28.0

* Remove unnecessary heap allocation

* Upgrade sea-query-binder

* Upgrade sea-schema

* Fix

* Upgrade sea-schema

* refactoring

Co-authored-by: Ivan Krivosheev <py.krivosheev@gmail.com>
2023-01-05 20:41:28 +08:00
Billy Chan
e927a0e5f5
Execute unprepared statement (#1327) 2023-01-05 14:08:18 +08:00
Billy Chan
d332afa99c
Get SQLx connection pool (#1297) 2023-01-05 14:08:10 +08:00
Billy Chan
2f00a8757d
Merge branch 'master' into select-into-tuple 2022-12-20 15:51:06 +08:00
Billy Chan
3cd834d40c
docs 2022-12-20 15:43:03 +08:00
Billy Chan
7757a46c46
clippy 2022-12-16 21:36:00 +08:00
Antonio Scandurra
df2dcdabac
Prevent returning connections to pool with a positive transaction depth (#1283)
Mark transaction as closed *only* after commit/rollback succeeds.

Previously, `open` on the transaction would be set to `false` prior to attempting
to commit or rollback the transaction. When the operation failed, for example, due
to a serialization failure with a serializable isolation level, this would leave
the transaction in an inconsistent state, where it thought it was closed but really
it was still open. The connection would then be returned to the connection pool with
a transaction depth of 1, causing a savepoint to be erroneously created the next time
a transaction was created for the connection.

By waiting to set `open` to `false` until the commit/rollback succeeds, a failure
to do either will result in us correctly rolling back the transaction when dropping
it, ensuring that the connection is returned to the pool with a transaction depth
of 0. Note that this is consistent with how `sqlx` handles transactions.

We attempted to write a test, but had a very difficult time forcing postgres to fail
to commit a transaction. We found that it would block our requests instead when creating
conflicting updates, and we couldn't find any information about when it blocks vs when
transaction commits fail.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-12-16 21:11:51 +08:00
Billy Chan
70c4a3a23e
Select into tuple 2022-12-15 21:24:10 +08:00
Marco Napetti
824158457b
Transactions Isolation level and Access mode (#1230)
* Transactions Isolation level and Access mode

* Fix typo

* Fix clippy lints
2022-12-02 13:09:23 +08:00
Chris Tsang
ca403da0d9
Mock DbErr (#1241)
* Mock Err

* Test mock errors
2022-11-24 13:42:47 +08:00
Billy Chan
115e19a95e
Close connection explicitly (#1236)
* Close connection and transaction

* Close connection only
2022-11-22 13:55:03 +08:00
Marco Napetti
9d25ee9ac1
use GAT to elide StreamTrait lifetime (#1161) 2022-11-06 12:55:21 +08:00
Marco Napetti
9f2a6dc40b
Fix transaction metrics (#1165) 2022-10-28 01:00:04 +08:00
Billy Chan
b5b9790252
Support array datatype in PostgreSQL (#1132)
* PostgreSQL array (draft)

* Fixup

* Fixup

* Fixup

* Fixup

* Fixup

* Refactoring

* generate entity for Postgres array fields

* Add tests

* Update Cargo.toml

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2022-10-23 18:26:57 +08:00
Billy Chan
b22db842e4
Run migrations on PostgreSQL schema (#1056)
* Run migrations on PostgreSQL schema

* fmt

* fmt & clippy

* clippy

* [cli] update helper text
2022-10-17 17:16:00 +08:00
Chris Tsang
5d752e60b9
Merge pull request #1002 from SeaQL/better-errors
Better error system
2022-10-07 00:24:41 +08:00
Billy Chan
968fc2e678
Configure acquire timeout for connection pool (#897)
* Reproduce "failed to acquire connection from pool" error

* Configure acquire_timeout

* Add tests

* Fixup

* Remove tests
2022-09-19 23:50:11 +08:00
Billy Chan
0efdfc6742
Typo 2022-09-01 15:57:58 +08:00
Chris Tsang
85533a3bb3 Give up and fix tests 2022-08-28 14:54:26 +08:00
Chris Tsang
0ce0f49551 Refactor SqlxError; 2022-08-28 13:51:21 +08:00
mohs8421
fe6c40dd75
Introducing sqlx-error feature (#750)
* feat: Introducing feature "sqlx-error"

Purpose of this feature is to not convert errors given from sqlx into strings to ease further analysis of the error and react to it accordingly. This implementation uses a feature switch and an additional error kind to avoid interfering with existing implementations without this feature enabled.
See discussion https://github.com/SeaQL/sea-orm/discussions/709

* fix: Align feature "sqlx-error" with merged Migration error kind

Due to the merge, an other error kind had been introduced and the DbErr became Eq and Clone, however Eq cannot easily be derived from, so I went back to PartialEq, and since the sqlx error does not implement clone, this was converted into an Arc, to allow cloning of the new kind too.

* fix: Repairing failing jobs

Several jobs had failed as I missed to correct the return values of a few methods in transaction.rs and had a wrong understanding of map_err at that point.

* feat: realigning with latest changes in sea-orm, different approach

Instead of the former approach to introduce a new error kind, now the existing error types get extended, for now only Exec and Query, because these are the most relevant for the requirement context.
Afterwards it might still be possible to add some further detail information.
See discussion https://github.com/SeaQL/sea-orm/discussions/709

* Update src/driver/sqlx_mysql.rs

Integrating fixes done by @Sculas

Co-authored-by: Sculas <contact@sculas.xyz>

* Update src/driver/sqlx_postgres.rs

Integrating fixes done by @Sculas

Co-authored-by: Sculas <contact@sculas.xyz>

* Update src/driver/sqlx_sqlite.rs

Integrating fixes done by @Sculas

Co-authored-by: Sculas <contact@sculas.xyz>

* feat: reworking feature with thiserror

Following the latest suggestions I changed the implementation to utilize `thiserror`.
Now there are more error kinds to be able to see the different kinds directly in src/error.rs
To ensure the behaviour is as expected, I also introduce a further test, which checks for a uniqueness failure.

Co-authored-by: Sculas <contact@sculas.xyz>
2022-08-28 11:13:51 +08:00
Billy Chan
43495de0aa
Fix clippy warnings - 1 (#967)
* Fix clippy warnings

* cargo fmt

* Fix clippy warnings

* cargo fmt
2022-08-12 20:02:53 +08:00
sjud
3d409608e1
removing async_trait from non async trait in connection.rs (#737) 2022-07-17 15:12:25 +08:00
Billy Chan
1a3e8c456a
[CI] run clippy checks & fix clippy warnings (#840)
* Run clippy checks

* Fix clippy warnings

* Clippy checks for `sea-orm-*` crates

* Fix clippy warnings

* Fixup
2022-07-10 15:38:38 +08:00
Billy Chan
d6831e5295
Bump version of sqlx, sea-query, sea-schema, time and uuid (#834)
* Bump version of sqlx, sea-query, sea-schema, time and uuid

* PostgreSQL `u32` was wrapped in `Oid` (launchbadge/sqlx#1602)

* Update test cases

* Fix clippy warnings

* cargo fmt

* Fix clippy warnings

* Bump sea-schema to ^0.9.2

* Update test cases

* Pin on sea-query minor version
2022-07-05 01:05:11 +08:00
Billy Chan
80d35a9d18
cargo fmt 2022-06-28 16:13:38 +08:00
Chris Tsang
d074fafdde
Merge pull request #778 from nappa85/master
Stream metrics
2022-06-26 21:18:00 +08:00
SandaruKasa
4f26b4a585
sqlx_logging_level, a wrapper around sqlx::ConnectOptions::log_statements (#800)
* sqlx_logging_level

* ` = { version = "..." }`
2022-06-26 18:29:44 +08:00
cache-missing
73af72200a feat(sqlite3): support set sqlcipher key 2022-06-13 08:42:14 +08:00
Marco Napetti
0e1c825e9e Stream metrics 2022-05-31 12:38:38 +02:00
Marco Napetti
e80aa07c7c
Add Send to StreamTrait (#622)
* update ouroboros

* Add Send to StreamTrait
2022-03-22 17:17:07 +08:00
Billy Chan
f3a7a1398a
Merge branch 'master' into pulls/471 2022-03-07 15:52:12 +08:00
Bastian
47f2f4cec8
Easy joins with MockDatabase #447 (#455)
* Easy joins with MockDatabase #447

* fix MR

* add unit test

* Add test cases

* Cargo fmt

Co-authored-by: Bastian Schubert <bastian.schubert@crosscard.com>
Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2022-02-06 14:45:51 +08:00
Chris Tsang
e305c6669c
Merge pull request #493 from SeaQL/max-lifetime-connection-opt
Add `max_lifetime` connection option
2022-02-05 20:50:39 +08:00
Billy Chan
8eb095385d Migration (#335)
* Refactor `ConnectionTrait`

* Refactoring

* Build index & foreign key statements

* Fix imports

* Fixup

* Rocket example with migration

* async-std compatible with the tokio 1.0 runtime

* Use reexported dependency

* Compile without selecting any db backend

* Updating sea-orm-cli dep

* sea-orm-cli migrate commands

* cargo fmt

* Test [cli]

* Refactoring

* Clap app name should be "sea-orm-cli"

* Correctly capture MIGRATION_DIR

* Rename README

* Add `sea-orm-cli migrate init` command

* Update README

* Try restructured sea-query dependency (SeaQL/sea-schema#41)

* Set `DATABASE_URL` environment variable
2022-02-05 20:34:54 +08:00
Billy Chan
15dc9576ea
Add max_lifetime connection option 2022-01-28 11:51:44 +08:00
Sebastian Pütz
949e3115f5 Make TransactionStream::build sync 2022-01-19 23:55:26 +01:00
Sebastian Pütz
f012ccaec3 Add Send bound to streams. 2022-01-19 20:46:10 +01:00
Billy Chan
006d35313b
Fix clippy warnings 2021-12-17 11:39:53 +08:00
Billy Chan
4072e74284
cargo fmt 2021-12-17 11:14:54 +08:00
Marco Napetti
9a342546f3 use macro to simplify code, add failure boolean 2021-12-10 10:09:09 +01:00
Marco Napetti
aaf11dd265 Into doesn't works 2021-12-09 19:17:41 +01:00