90 Commits

Author SHA1 Message Date
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
a766500ebf
Cont. "Enable convert from ActiveModel to Model" (#990)
* Changelog

* Enable convert from ActiveModel to Model (#725)

* feat: enable convert from ActiveModel to Model

* feat: add tests for converting from ActiveModel to Model

* cargo fmt

* Refactoring

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>

* Fix clippy warnings

* Use error type

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
Co-authored-by: greenhandatsjtu <40566803+greenhandatsjtu@users.noreply.github.com>
2022-10-23 23:12:22 +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
Billy Chan
8ecb4fccba
Implement IntoActiveValue for Vec<u8> types 2022-09-15 15:40:34 +08:00
Jimmy Cuadra
bde43f51f8 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!
2022-09-14 22:58:05 -07:00
Chris Tsang
1609e4c743 Edit 2022-05-15 17:44:23 +08:00
Kirawi
23e95761ca
add is_changed to ActiveModelTrait (#683)
* add is_changed to ActiveModelTrait

* add test for `ActiveModelTrait::is_changed()`
2022-05-09 21:58:20 +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
351efd0d6b
Update ActiveModel by JSON (#492)
* Update ActiveModel by JSON

* Add `ActiveModel::from_json`

* Update test cases
2022-03-13 18:41:32 +08:00
Ken-Miura
483de17da8
Describe default value of ActiveValue on document (#556) 2022-03-02 12:24:49 +08: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
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
0f5516b6bf
fix: support up to 6-ary composite primary key (#423) 2022-01-14 01:16:39 +08:00
Chris Tsang
d5c9c65079 Revert save to return Self 2021-12-26 00:13:56 +08:00
Chris Tsang
09fd9ba725 Docs 2021-12-19 02:23:23 +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
7298fdeda9
Rewrite doctests 2021-11-16 17:35:49 +08:00
Billy Chan
4c147a2d24
Rewrite doctests 2021-11-16 16:27:54 +08:00
Billy Chan
fd50ffd5ea
Merge remote-tracking branch 'origin/master' into returning 2021-11-16 14:44:12 +08:00
Chris Tsang
5f2fa55253 Edit docs 2021-11-14 16:58:52 +08:00
Billy Chan
a977572762
Update with returning for Postgres 2021-11-05 22:13:52 +08:00
Billy Chan
c39a3b8cb2
Insert with returning for Postgres 2021-11-05 18:20:25 +08:00
Billy Chan
fcf3ea9407
Try fixing some doctest errors 2021-10-31 14:40:36 +08:00
Charles Chege
30814f0053 Provide further exaplanation for
pub struct ActiveValue<V>

Add a code snippet for a simple example
2021-10-31 09:03:02 +03:00
Charles Chege
a22350914c Solutions for doc tests 2021-10-30 18:55:53 +03:00
Charles Chege
870ca3ffb0 Run fmt --all 2021-10-30 12:00:07 +03:00
Charles Chege
e0023611a2 Improve documentation for the drivers and the entity
Provide module level code example on how to create an Entity, Model, ActiveModel, Column and PrimaryKey
2021-10-30 11:15:43 +03:00
Charles Chege
db098d1a03 Documetation for the entity module 2021-10-29 10:39:16 +03:00
Chris Tsang
c0761a949b cargo fmt 2021-10-19 18:50:45 +08:00
Chris Tsang
10b101b142 Test case for DeriveIntoActiveModel 2021-10-16 17:46:08 +08:00
Billy Chan
aa5ccb9216
Hotfix - ActiveModel::insert() trigger ActiveModelBehavior::after_save() 2021-10-15 17:43:39 +08:00
Chris Tsang
760c439c83 Unit test DeriveIntoActiveModel 2021-10-13 18:58:00 +08:00
Chris Tsang
d5e95b0f8f
Merge pull request #240 from Acidic9/feat/into-active-model-derive
Add derive `DeriveIntoActiveModel` and `IntoActiveValue` trait
2021-10-13 18:30:09 +08:00
Billy Chan
6ecc3138c3
Use new ActiveValue::into_value() 2021-10-12 21:14:40 +08:00
Billy Chan
75e625fee9
ActiveModelBehavior without db connection 2021-10-12 20:42:42 +08:00
Billy Chan
5339696da2
Merge branch 'master' into active-model-behavior 2021-10-12 20:37:00 +08:00
Ari Seyhun
b582d3aac9 Merge branch 'master' of github.com:SeaQL/sea-orm into feat/into-active-model-derive 2021-10-12 18:31:34 +07:00
Ari Seyhun
1a9704eaad Add support for Option<Option<T>> into active model 2021-10-12 18:27:45 +07:00
Chris Tsang
7bc6477091 Merge branch 'master' into transaction-3 2021-10-12 14:24:35 +08:00
Chris Tsang
3fd33ab53c
Merge branch 'master' into last-insert-id 2021-10-12 13:59:41 +08:00
Ari Seyhun
8667b2ddfc Add trait IntoActiveValue 2021-10-11 14:33:47 +07:00
Billy Chan
23215c8dd5
fix clippy warnings 2021-10-08 18:22:25 +08:00
Billy Chan
2f90207d64
Remove PrimaryKeyValue trait 2021-10-08 18:10:19 +08:00
Billy Chan
35b8eb9a4d
ActiveValue::take() & ActiveValue::into_value() without unwrap() 2021-10-04 12:17:31 +08:00
Marco Napetti
02ebc9745c Transaction 3 2021-10-04 11:39:16 +08:00
Billy Chan
5497810afb
Remove unnecessary trait bounds 2021-09-30 11:49:27 +08:00
Billy Chan
ef1eb577b7
Update ActiveModelBehavior API 2021-09-30 10:31:58 +08:00