311 Commits

Author SHA1 Message Date
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
Billy Chan
96a776ae9d
test(Schema): add test cases for Schema::create_enum_from_entity & Schema::create_enum_from_active_enum 2021-12-22 16:14:17 +08:00
Billy Chan
17631512bb
feat(Model): add wrapper method delete 2021-12-21 18:24:05 +08:00
Billy Chan
adfb9ead54
Rework ActiveValue (#340)
* WIP

* Fixup

* Fixup

* Update docs & rename `unset`

* Deprecate `Unset()` and reexport `ActiveValue::NotSet`

* Docs

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2021-12-19 02:22:30 +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
006d35313b
Fix clippy warnings 2021-12-17 11:39:53 +08:00
Billy Chan
f5f6a6774f
Codegen ActiveEnum & Create Enum From ActiveEnum (#348) 2021-12-15 00:52:50 +08:00
Billy Chan
66a005237c
Update sea-orm to depends on sea-query 0.20.0 2021-12-12 23:03:11 +08:00
Billy Chan
a9f6275a9e Run timestamp_tests for all databases 2021-12-11 14:25:45 +08:00
Billy Chan
0f164b62d5
Fix related & linked with enum columns (#376)
* Fix related & linked with enum columns

* Add test cases
2021-12-10 23:41:43 +08:00
Billy Chan
0e4221bd72
Refactoring 2021-11-17 21:24:06 +08:00
Chris Tsang
0deedddf28
Merge pull request #292 from SeaQL/returning
Returning
2021-11-17 17:41:28 +08:00
Chris Tsang
aff988bd94
Merge pull request #324 from SeaQL/hotfix-custom-types
Unknown types could be a newtypes instead of `ActiveEnum`
2021-11-17 16:47:28 +08:00
Billy Chan
0f904e02f0
Refactoring 2021-11-17 10:38:02 +08:00
Billy Chan
fd50ffd5ea
Merge remote-tracking branch 'origin/master' into returning 2021-11-16 14:44:12 +08:00
Billy Chan
3d5f4424a8
Fixup 2021-11-16 13:09:07 +08:00
Billy Chan
36886e74cd
Testing & fixup 2021-11-16 12:04:21 +08:00
Billy Chan
f504ad1eef
Refactor Schema 2021-11-11 15:11:52 +08:00
Billy Chan
f975223d9e
Fixup 2021-11-10 16:08:06 +08:00
Billy Chan
ac804a1642
Imports PaginatorTrait by default making it backward compatible 2021-11-10 15:26:29 +08:00
Billy Chan
1905f62430
cargo fmt 2021-11-10 14:58:06 +08:00
Billy Chan
66c23c85db
Revert MySQL & SQLite returning support 2021-11-10 14:42:19 +08:00
jasper
05181994d3 Move count to PaginatorTrait 2021-11-10 08:57:05 +08:00
jasper
4b11a10680 Update examples and test 2021-11-09 22:29:48 +08:00