Closed fswdev closed 2 months ago
Hey @fswdev, thanks for the quick fix!
From the CHANGELOG. In v0.5, heck
employ another way to determine the word boundaries to apply the word casing conversion. I guess that's why upgrading to v0.5 fix the issue?
- Remove non-additive
unicode
feature. The library now useschar::is_alphanumeric
instead of theunicode-segmentation
library to determine word boundaries in all cases.
I support upgrading heck
to v0.5. However, we need a more comprehensive testing before merging this PR.
@billy1624 where's the file containing the test cases for this macro?
@fswdev can you add some test cases there to ensure it will not break in the future?
@billy1624 where's the file containing the test cases for this macro?
@fswdev can you add some test cases there to ensure it will not break in the future?
dear @tyt2y3 :
//Database structure (Show two examples of Chinese fields)
CREATE Table ` t truck type `(
`Id ` bigint UNSIGNED NOT NULL AUTO-INCREMENT,
`truck13整车 whole vehicle 'double NULL DEFAULT NULL COMMENT' model 1 ',
`truck13配货 distribution 'double NULL DEFAULT NULL COMMENT' model 2 ',
......
)ENGINE=InnoDB AUTO-INCREMENT=1 CHARACTER SET=utf8mb4 COLLATE=utf8mb4:0900-ai_ci ROW-FORMAT=DYNAMIC;
//Generated RUST code
Use sea_orm:: entity:: prelude:: *;
#[derived (Clone, Debug, PartialEq, DeriveEntityModel)]//<-- The "DeriveEntityModel" macro can also cause errors
#[sea_orm (tablename="tcity")]
Pub struct model{
#[sea_orm (primary_key)]
Pub id: u64,
#[sea_orm (columnname="truck13整车 whole vehicle", columntype="Double", nullable)]
Pub truck13: Option<f64>,//<--- * * Error 1**
#[sea_orm (columnname="truck13配货 distribution", columntype="Double", nullable)]
Pub truck13: Option<f64>,//<--- * * Error 2**
}
I found two application scenarios affected by this bug
I don't know how to do the test cases you mentioned, but if you can provide more details, I can try to do it (I am not particularly proficient in using Rust) :)
PR Info
Bug Fixes
Fixed the issue of losing Chinese characters when converting ORM fields when database field names contain Chinese characters For example:
The cause of the problem:
On line 95 of the "crates/sea-orm-macros-0.12.15/src/derives/entity_model.rs" file: Thrown by calling the trait "to_uper_camel_case" of heck.
Two solutions:
The first method:
Dependency between two files sea-orm-codegen/Cargo.toml sea-orm-macros/Cargo.toml [dependencies] heck = { version = "0.4", features = ["unicode"] }
Second method: (Recommended, the conversion result looks more reasonable)
Dependency between two files sea-orm-codegen/Cargo.toml sea-orm-macros/Cargo.toml [dependencies] heck = { version = "0.5.0"}