284 Commits

Author SHA1 Message Date
Chris Tsang
eeec2cf06f
Merge pull request #1238 from karatakis/dataloader
[PIP] Simple data loader
2022-12-28 15:59:04 +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
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
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
Chris Tsang
bfe6eb39d5
Cursor pagination (#822)
* Cursor pagination

* Apply filter / range filter on cursor; Allow non-primary key filter

* Fixup

* Update cursor API

* Cursor pagination with composite keys

* Docs

* Rename cursor() to cursor_by()

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2022-07-10 15:08: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
ab2f784701
(de)serialize custom JSON types - 2 (#794)
* de(serialize) custom JSON types

* Rename DeriveTryGetableFromJson -> FromJsonQueryResult

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2022-07-01 01:27:46 +08:00
Chris Tsang
12ec00272c Revert "Cursor Pagination (#754)"
This reverts commit 6f9dbd260e6e004c369abe0019b4374253db7d3b.
2022-06-26 18:23:47 +08:00
Billy Chan
6f9dbd260e
Cursor Pagination (#754)
* Cursor pagination

* Apply filter / range filter on cursor; Allow non-primary key filter

* Fixup

* Update cursor API

* Cursor pagination with composite keys

* Docs
2022-06-26 17:48:00 +08:00
Billy Chan
fff738a706
cargo fmt 2022-06-21 11:12:28 +08:00
Billy Chan
5cf4d6022b
Vector of string save as serialized format in db (#783) 2022-06-12 22:23:30 +08:00
Chris Tsang
1a37212940 Comment 2022-05-11 21:53:02 +08:00
Billy Chan
cdc70f4fd9
Insert Default (#589)
* Insert default

* Update sea-query

* Fixup

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2022-05-09 23:46:38 +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
c504f42cb3
Fixing and testing into_json of various field types (#539)
* Fixing and testing `into_json` of various types

* Support `into_json` for UUID

* Testing `into_json` for UUID

* Fixup
2022-03-24 22:38:45 +08:00
Shouvik Ghosh
12f66618f9
Added delete_by_id (#590)
* Added delete_by_id

* Added an integration test

* Added composite key example

* Remove extra find_by_id in delete_by_id test

* Added unit test with composite primary key
2022-03-21 14:41:05 +08:00
Billy Chan
9687819a7e
Supports time crate 2022-03-13 18:18:15 +08:00
Chris Tsang
b8a7ae7351 Revert "Insert Default - Inserting ActiveModel with all attributes NotSet (#432)"
This reverts commit 33a87d79b1a789e8b47ed21bf22384289af7a487.
2022-02-06 21:52:08 +08:00
Chris Tsang
645a420eb1 cargo fmt 2022-02-06 14:47:45 +08:00
Chris Tsang
33a87d79b1 Insert Default - Inserting ActiveModel with all attributes NotSet (#432)
* feat: apply alias on `ColumnRef::SchemaTableColumn`

* build: update sea-query dependency

* feat: insert default

* Use sea-query 0.21

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2022-02-06 14:39:46 +08:00
Chris Tsang
e63d463155
Merge pull request #489 from SeaQL/date-time-utc-local
Support `DateTime<Utc>` & `DateTime<Local>`
2022-02-01 15:25:39 +08:00
Billy Chan
8145088814 Refactoring
`ColumnDef` with default value

Cargo fmt

Update docs

Fixup

Support `DateTimeLocal`

Update docs

Codegen write db timestamp column as `DateTimeUtc` type

Update dependency

Merge branch 'sea-query/add-new-column-ref' into pr/429

feat: apply alias on `ColumnRef::SchemaTableColumn`
2022-02-01 14:29:03 +08:00
Charles Chege
52f38a10ea Support the use of chrono::DateTime<Utc> in sea-orm
Add documentation for this

Temporarily use a fork to include new Sea-query code

Add tests for DateTimeUtc

Solve Github actions error by add the code to create a table

Assertion accuracy tests

Rectify incorrect format
2022-02-01 14:27:33 +08:00
Billy Chan
76c0d7fff5
Name conflict of foreign key constraints when two entities have more than one foreign keys (#417)
* fix: name conflict of foreign key constraints when two entities have more than one fk

* test: update test case's foreign keys

* feat: override default name of foreign key constraint
2022-01-28 01:03:24 +08:00
Chris Tsang
d5c9c65079 Revert save to return Self 2021-12-26 00:13:56 +08:00
Chris Tsang
65fe5910ec
Merge pull request #396 from SeaQL/active-value-continue
Add wrapper method `ModelTrait::delete`
2021-12-24 23:51:08 +08:00