Skip to content

Commit

Permalink
active enum fail safe SeaQL/sea-orm#1374
Browse files Browse the repository at this point in the history
  • Loading branch information
darkmmon committed Jul 12, 2023
1 parent 1da2436 commit 5791b83
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SeaORM/docs/0.12.x-CHANGELOG_temp.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ assert!(matches!(res, Ok(TryInsertResult::Conflicted)));
* Upgrade `sea-schema` to `0.12` https://github.com/SeaQL/sea-orm/pull/1562
* Upgrade `clap` to `4.3` https://github.com/SeaQL/sea-orm/pull/1468

================================ All Changes above was being Documented ================================
### Bug Fixes

* Fixed `DeriveActiveEnum` throwing errors because `string_value` consists non-UAX#31 compliant characters https://github.com/SeaQL/sea-orm/pull/1374
Expand Down Expand Up @@ -364,6 +363,7 @@ pub enum StringValueVariant {
_0x300x20123,
}
```
================================ All Changes above was being Documented ================================
* [sea-orm-cli] The implementation of `Related<R>` with `via` and `to` methods will not be generated if there exists multiple paths via an intermediate table. Like in the schema defined below - Path 1. `users <-> users_votes <-> bills`, Path 2. `users <-> users_saved_bills <-> bills` https://github.com/SeaQL/sea-orm/pull/1435
```sql
CREATE TABLE users
Expand Down
35 changes: 35 additions & 0 deletions SeaORM/docs/09-schema-statement/02-create-enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,41 @@ assert_eq!(
);
```

Note that non-UAX#31 compliant characters would be converted.
For example,
```rust
#[derive(Clone, Debug, PartialEq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(None)")]
pub enum StringValue {
#[sea_orm(string_value = "")]
Member1,
#[sea_orm(string_value = "$")]
Member2,
#[sea_orm(string_value = "$$")]
Member3,
#[sea_orm(string_value = "AB")]
Member4,
#[sea_orm(string_value = "A_B")]
Member5,
#[sea_orm(string_value = "A$B")]
Member6,
#[sea_orm(string_value = "0 123")]
Member7,
}
```
will now produce the following Variant Enum:
```rust
pub enum StringValueVariant {
__Empty,
_0x24,
_0x240x24,
Ab,
A0x5Fb,
A0x24B,
_0x300x20123,
}
```

## Native Database Enum

Enum support is different across databases. Let's go through them one-by-one.
Expand Down

0 comments on commit 5791b83

Please sign in to comment.