307 Commits

Author SHA1 Message Date
Chris Tsang
d11998bf9e More tests 2023-02-02 01:31:35 +08:00
Billy Chan
b21abf617f
Fix clippy warnings (#1437) 2023-01-31 16:46:44 +08:00
Billy Chan
4e3a45c2f7
Fix clippy warnings (#1436) 2023-01-31 15:52:57 +08:00
Billy Chan
a6bd91a78b
Use ActiveEnum field as composite primary key (#1414)
* Use ActiveEnum field as part of composite primary key

* Try unique constraint failed
2023-01-30 21:47:49 +08:00
Billy Chan
08a5e87e22
Replace SeaORM's ColumnType (#1395)
* Replace SeaORM's `ColumnType`

* Bump SeaQuery's version

* Fix merge conflict

* refactor
2023-01-29 11:06:01 +08:00
Billy Chan
71dbffc725
Fix clippy (#1426)
* Fix clippy

* Fix clippy
2023-01-27 18:50:20 +08:00
Chris Tsang
b3e4d1c1cf RecordNotFound -> RecordNotUpdated 2023-01-25 15:43:44 +08:00
Chris Tsang
5cdcdbfc1c Add testcase 2023-01-19 01:38:03 +08:00
Chris Tsang
03207fbda9 Use rows_affected when DB does not support returning 2023-01-18 21:18:04 +08:00
Billy Chan
e2b796b093
Cont. feat: expose database connection to ActiveModelBehaviour's methods (#1328)
* feat: expose database connection to `ActiveModelBehaviour`'s methods (#1145)

* Make ActiveModelTrait async

* Add tests

* refactoring

Co-authored-by: teenjuna <53595243+teenjuna@users.noreply.github.com>
2023-01-12 17:22:46 +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
c49a8ac843
Fix merge conflict (#1386)
* Fix merge conflict

* remove unnecessary clone
2023-01-11 15:27:34 +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
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
Billy Chan
4f5a15a99f
Support various UUID formats that are available in uuid::fmt module (#1325)
* Support various UUID formats that are available in `uuid::fmt` module

* clippy

* fixup
2023-01-11 14:13:15 +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
5c93253877 Tests 2023-01-09 14:46:19 +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
Chris Tsang
eeec2cf06f
Merge pull request #1238 from karatakis/dataloader
[PIP] Simple data loader
2022-12-28 15:59:04 +08:00
Billy Chan
1135c117c3
fixup 2022-12-20 15:56:42 +08:00
Billy Chan
2f00a8757d
Merge branch 'master' into select-into-tuple 2022-12-20 15:51:06 +08:00
Billy Chan
d205338f3f
Try custom vector field (#1273) 2022-12-19 17:08:32 +08:00
Billy Chan
69eb4b8ea8
Refactor the use of deprecated chrono methods (#1312) 2022-12-16 18:14:25 +08:00
Billy Chan
0be16bad16
Add tests 2022-12-15 21:24:18 +08:00
Billy Chan
70c4a3a23e
Select into tuple 2022-12-15 21:24:10 +08:00
Billy Chan
7838782718 Transaction tests 2022-12-02 13:37:37 +08:00
Billy Chan
08cb44028e
Support bigdecimal::BigDecimal (#1258)
* Fix: fields with type `Option<T>` are always nullable

* Support BigDecimal
2022-12-01 12:53:19 +08:00
Panagiotis Karatakis
f3910c329b Fix shared related item 2022-11-25 12:01:58 +02:00
Chris Tsang
45b391f434 Improve testcase 2022-11-23 23:47:14 +08:00
Chris Tsang
6c7a162f05 cargo fmt 2022-11-23 22:47:41 +08:00
Panagiotis Karatakis
4323a0cb07 Add integration tests 2022-11-22 13:46:22 +02:00
Billy Chan
4d8645ae8b
Support Vector of enum for Postgres (#1210)
* Support Vector of enum for Postgres

* Fix clippy

* Add tests for integer array

* Fix dependency

* Bump sea-query to 0.27.2

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2022-11-15 13:50:05 +08:00
Billy Chan
73e56e5531
Filter rows with IS IN enum values expression (#1183)
* [demo] filter rows with enum value is in list

* Fix clippy
2022-11-15 13:20:47 +08:00
Billy Chan
1be6673f0e
Fix DeriveActiveEnum expand enum variant starts with number (#1219) 2022-11-15 10:56:25 +08:00
Billy Chan
fdb3cff29f
SQLite support time crate (#995)
* SQLite support `time` crate

* Serialize time types for SQLite query results
2022-10-27 14:35:39 +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
Ivan Krivosheev
3219e6ff42
Merge branch 'master' into sea-query-v0.27 2022-10-17 21:50:48 +03:00
Billy Chan
a0fd72e635
Serialize time types as serde_json::Value (#1042)
* Implement `IntoActiveValue` for `time` types.

I tried to implement a [custom active
model](https://www.sea-ql.org/SeaORM/docs/advanced-query/custom-active-model/),
and one of the columns was `Option<TimeDateTimeWithTimeZone>`. I got a
compiler error:

```
error[E0277]: the trait bound `std::option::Option<sea_orm::prelude::TimeDateTimeWithTimeZone>: IntoActiveValue<_>` is not satisfied
```

Looking into the source code, it seemed a simple oversight that this
trait was implemented for the `chrono` types but not the `time` types,
and it was easy enough to fix since there's already a macro to implement
it for new types.

I also noticed that the `time` types are not accounted for in
`src/query/json.rs` while the `chrono` types are, which I assume is also
an oversight. However, I don't have a need for that at this point and
the fix for that seemed less trivial, so I'm just bringing it to your
attention.

Thanks for SeaORM!

* Implement `IntoActiveValue` for `Vec<u8>` types

* Add tests to double check and prevent it from happening again

* Add docs

* Fixup

* Serialize `time` types as `serde_json::Value`

Co-authored-by: Jimmy Cuadra <jimmy@jimmycuadra.com>
2022-10-18 00:04:03 +08:00
Billy Chan
29da37b4f2
Merge branch 'master' into sea-query-v0.27 2022-10-17 17:53:41 +08:00
Billy Chan
671d79469a
Fixup 2022-10-17 17:25:35 +08:00
Billy Chan
e76cbb9fe1
Add into_model & into_json for Cursor (#1112) 2022-10-16 19:02:48 +08:00
wdcocq
880147c596
Blanket IntoActiveValue implementations so custom db types are supported (#833)
* Add blanket implementations of IntoActiveValue for optional values

* Add a compile test for DeriveIntoActiveModel
2022-10-11 23:47:17 +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
77bddd85a5
Fixup 2022-09-22 15:07:37 +08:00
Billy Chan
1035bbb431
Fixup 2022-09-15 16:44:31 +08:00
Billy Chan
7c591049be
Add docs 2022-09-15 16:18:13 +08:00
Billy Chan
0d31a012cc
Add tests to double check and prevent it from happening again 2022-09-15 15:41:13 +08:00
Chris Tsang
85533a3bb3 Give up and fix tests 2022-08-28 14:54:26 +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