42 Commits

Author SHA1 Message Date
Billy Chan
036edf9d70
Noop when update without providing any values (#1384)
* Noop when update without providing any values

* Add tests

* Update Cargo.toml

* Bump SeaQuery's version

* Fixup

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2023-01-26 17:12:50 +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
0756adf647
find_by_id and delete_by_id take any Into primary key value (#1362) 2023-01-11 15:28:10 +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
e-rhodes
69612fa507
Fix typo in error name (#1180)
* fix typo in error name

* fixed typo in docs

Co-authored-by: erhodes <erik@space-nav.com>
2022-11-06 14:18:07 +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
75e2570811
Fix Rust 1.64 clippy (#1064) 2022-09-23 15:32:03 +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
Billy Chan
0efdfc6742
Typo 2022-09-01 15:57:58 +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
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
65f9c70dd3
cargo fmt 2021-11-18 18:07:24 +08:00
Billy Chan
42404eb525
Fixup 2021-11-16 17:56:22 +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
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
2f7cffa74d
Fix test cases 2021-11-08 15:12:56 +08:00
Billy Chan
623873678b
Handle "None of the database rows are affected" for Postgres 2021-11-08 15:12:47 +08:00
Billy Chan
50605c731b
FIXME: breaking behaviors 2021-11-05 22:39:25 +08:00
Billy Chan
a977572762
Update with returning for Postgres 2021-11-05 22:13:52 +08:00
Charles Chege
817e9bdd23 Documetation for the executor module 2021-10-29 10:38:55 +03: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
a2ec6cd351 Rename MockTransaction -> Transaction 2021-10-07 18:00:11 +08:00
Chris Tsang
30b90076ae Merge pull request #211 from SeaQL/error-no-record-updated
Throw error if none of the db rows are affected
2021-10-07 16:59:42 +08:00
Chris Tsang
e7b822c65d cargo fmt 2021-10-04 11:44:02 +08:00
Marco Napetti
02ebc9745c Transaction 3 2021-10-04 11:39:16 +08:00
Billy Chan
e83cc63e3a Replacing Syntax & *BuilderBackend with DatabaseBackend 2021-07-16 00:28:03 +08:00
Chris Tsang
6ff5a32b7a cargo fmt 2021-07-11 22:08:37 +08:00
Chris Tsang
0298cfb6af Rename to DbErr 2021-06-30 21:17:23 +08:00
Billy Chan
2a1173c174
Add & use OrmError (#36)
* Add & use OrmError

* Rename to SeaErr
2021-06-30 21:08:41 +08:00
Chris Tsang
5002c62b40 Use DatabaseConnection in place of Database 2021-06-19 17:28:07 +08:00
Chris Tsang
041d28aa26 Refactor 2021-06-19 16:56:53 +08:00
Chris Tsang
6b7ea75393 Mock Database Connection 2021-06-13 22:20:50 +08:00
Chris Tsang
c7057ab964 Organize code 2021-06-12 17:12:18 +08:00