Field name 'is_2fa' converted to 'is2fa' during insertion in SeaORM
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 734
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
Description
When generating entity with SeaORM, the insertion statement unexpectedly transforms the field name "is_2fa" into "is2fa".
Steps to Reproduce
- The command I executed to generate entity:
sea-orm-cli generate entity --database-url postgres://postgres:password@host:5432/dbname -o src/entity --with-serde both --expanded-format
2.
crate::entity::users::ActiveModel {
id: Set(Uuid::new_v4()),
username: Set(username),
password: Set(util::password::hash(password).await),
email: Set(email),
role: Set(crate::entity::sea_orm_active_enums::PermissionLevel::Reader),
is_2fa: Set(false),
..Default::default()
}
.insert(&tx)
.await?;
- The SQL generated by SeaORM.
INSERT INTO "users" ("id", "username", "password", "email", "role") VALUES ('2bd3cb70-0b26-4942-9aec-0bc0c37282da', 'admin', '$argon2id$v=19$m=19456,t=2,p=1$lLKmpXeiMihx8esjKmYV3A$ccgd1yniNX6W2b7HSflFic3Z29xuwznsBWqoA9tKrqg', 'initcoool@gmail.com', CAST('reader' AS permission_level)) RETURNING "id", "username", "password", "email", CAST("role" AS text), "email_verified", "is2fa", "avatar_url", "nickname", "gender", "birthday", "country", "region", "bio", "phone_number", "last_login_at", "verification_status", "created_at", "updated_at"
Versions
sea-orm-cli 0.12.14
sea-orm = { version = "0.12.14", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros", "debug-print"] }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the shown sea-orm-cli generate entity command and the ActiveModel insertion example against PostgreSQL. Compare the generated entity field is_2fa with the INSERT and RETURNING SQL; done means the field name remains consistent through insertion and the regression is covered by a test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, rust
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100