64 Commits

Author SHA1 Message Date
Chris Tsang
1f3fa1dc19 Changelog with Tweaks 2023-06-21 23:14:57 +08:00
darkmmon
6e7950158a
Do nothing on conflict (#1712)
* added Conflicted to TryInsertResult

clippy changes

fmt

change from basic if statement to matches

* changed to early return
2023-06-21 22:47:17 +08:00
darkmmon
92ea837cdf
Make insert statement not panic when inserting nothing (#1708)
* end-of-day commit (WIP)

* progress commit (WIP)

* refactored and added InsertAttempt

* async asjusting

* completed implementation for insertAttempt in execution
Added in tests for insertAttempt

* updated wording for new INSERT type

* removed InsertTrait
2023-06-20 17:17:18 +08:00
Billy Chan
91c4930391
Cleanup panic and unwrap (#1231)
* Add clippy linter checks

* Mock

* InnerConnection

* panic -> Err

* panic -> Err

* More panic -> Err

* Replace unwrap

* Fix clippy

* add clippy linters

* Refactor

* Dump DbErr::Mock

* Revert if...else rewrite

* Remove except

* DbErr helper functions

* Fix clippy

* Negative SQLite last_insert_rowid throw unreachable

* Update panics docs

* Fixup

* Fixup

* Fixup

* Fixup

* Revert adding `ExecResultHolder::Disconnected`

* More fixup

* Fix

* Revert adding `QueryResultRow::Disconnected`

* Fix

* Refactoring

* Fix

* Refactoring

* More refactoring

* More refactoring

* Fix

* Revert `InnerConnection::Disconnected`

* Revert breaking changes

* Fix

* Fix

* Fix

* Refactor `.take().expect()`

* Revert changing `if ... else` to `match` block

* Revert changing return type of `MockDatabaseConnection` transaction method

* Borrow sqlcipher_key

* Fetching unsupported type from query result will thrown `DbErr::Type(...)` error

* Revert adding `DatabaseConnection::try_into_transaction_log()` method

* Refactoring

* Refactoring
2023-02-02 00:02:53 +08:00
Billy Chan
51e6ad7170
Cast primary key column inside returning expression of insert statement (#1427) 2023-01-29 12:58:32 +08:00
Chris Tsang
03207fbda9 Use rows_affected when DB does not support returning 2023-01-18 21:18:04 +08:00
Chris Tsang
a465d1ebac Refactor 2 2023-01-18 20:46:02 +08:00
Chris Tsang
07d5f781ca Refactor 2023-01-18 20:08:10 +08:00
Chris Tsang
e5b69ebb73 Don't call last_insert_id if not needed 2023-01-18 19:06:06 +08:00
Billy Chan
e9df3aa01d
Casting columns as a different data type on select, insert and update (#1304)
* Cast select and value

* Refactoring

* Test casting Postgres citext

* Fixup

* Revert

* Add test cases

* Fixup

* Rename methods
2023-01-12 14:56:11 +08:00
Billy Chan
b5e984ca4a
Postgres insert many will throw RecordNotInserted error if non of them are being inserted (#1021) 2023-01-11 14:16:35 +08:00
Jacob Trueb
cf4657e127
Add Insert query execution without RETURNING clause (#1208) 2022-11-11 11:16:05 +08:00
Chris Tsang
5d752e60b9
Merge pull request #1002 from SeaQL/better-errors
Better error system
2022-10-07 00:24:41 +08:00
Chris Tsang
1225255431 Address comments 2022-09-14 00:28:24 +08:00
Billy Chan
a80c33ef4c
Rewrite enum and text casting (#973)
* Rewrite enum and text casting

* Add doc tests

* Refactoring
2022-09-05 00:38:12 +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
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
Allen
bdd9133aa6 fix lints and warnings
also clean up impl_into_active_value macro
2022-04-09 16:52:47 -07: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
5104cd3573
Insert & Update Return Model (#339)
* Update insert & update API

* Update test cases

* Update README

* Fix clippy warnings

* Fixup

* Fixup
2021-12-18 14:30:10 +08:00
Billy Chan
66c23c85db
Revert MySQL & SQLite returning support 2021-11-10 14:42:19 +08:00
Billy Chan
429b920ded
Fixup 2021-11-09 11:05:55 +08:00
Billy Chan
afdb1afeb8
This will fail loll 2021-11-08 22:12:09 +08:00
Billy Chan
30f43b64c6
Fixup 2021-11-08 19:03:06 +08:00
Billy Chan
0eafacc2a1
Try returning on MariaDB 2021-11-08 17:36:30 +08:00
Billy Chan
732d080020
Update docs 2021-11-08 15:24:51 +08:00
Billy Chan
52ff9430e1
Docs 2021-11-05 18:25:20 +08:00
Billy Chan
c39a3b8cb2
Insert with returning for Postgres 2021-11-05 18:20:25 +08:00
Billy Chan
c5468eb92f
Use "marlon-sousa/sea-query" 2021-11-05 12:41:49 +08:00
Charles Chege
817e9bdd23 Documetation for the executor module 2021-10-29 10:38:55 +03:00
Billy Chan
80d3ddc030
Use backed-up primary key as last insert id before getting it from db driver 2021-10-15 11:51:05 +08:00
Chris Tsang
069040be8b Tweak lifetime 2021-10-12 15:07:25 +08:00
Chris Tsang
3a6e55ced1 cargo fmt 2021-10-12 14:52:11 +08:00
Chris Tsang
7bc6477091 Merge branch 'master' into transaction-3 2021-10-12 14:24:35 +08:00
Billy Chan
2f90207d64
Remove PrimaryKeyValue trait 2021-10-08 18:10:19 +08:00
Chris Tsang
e7b822c65d cargo fmt 2021-10-04 11:44:02 +08:00
Chris Tsang
01a5c1c6dd Fix build errors 2021-10-04 11:43:21 +08:00
Marco Napetti
02ebc9745c Transaction 3 2021-10-04 11:39:16 +08:00
Billy Chan
3123a9d129
Fix git merge conflict 2021-09-30 11:40:27 +08:00
Billy Chan
b716c9ed57
cargo fmt 2021-09-30 11:19:26 +08:00
Billy Chan
97b95bf612
cargo fmt 2021-09-28 18:23:42 +08:00
Billy Chan
ba66de16b6
Merge remote-tracking branch 'origin/master' into last-insert-id 2021-09-28 18:23:30 +08:00
Chris Tsang
85eadd38d2 Change mock connector behavior to mock Postgres regardless of feature flags 2021-09-28 13:57:44 +08:00
Billy Chan
9bd537efe3
Fixup 2021-09-27 18:10:45 +08:00
Billy Chan
f79a417150
Remove ValueType: Default 2021-09-27 18:01:38 +08:00
Chris Tsang
a280a227d8 TODO 2021-09-17 16:04:07 +08:00
Billy Chan
e72d8a9e04
Use TryGetableMany 2021-09-02 11:26:40 +08:00
Billy Chan
d664985ea9
WIP 2021-09-01 23:24:43 +08:00
Billy Chan
a49f880f4f
WIP: composite primary keys 2021-09-01 18:23:23 +08:00