Field name 'is_2fa' converted to 'is2fa' during insertion in SeaORM
limitcool opened this issue · 3 comments
limitcool commented
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"] }
tyt2y3 commented
What is your Entity definition?
limitcool commented
This is my database model with some fields omitted。
CREATE TABLE "public"."users" (
"id" uuid NOT NULL,
"username" text COLLATE "pg_catalog"."default" NOT NULL,
"password" text COLLATE "pg_catalog"."default" NOT NULL,
"email" text COLLATE "pg_catalog"."default" NOT NULL,
"role" "public"."permission_level" NOT NULL,
"email_verified" bool NOT NULL DEFAULT false,
"is_2fa" bool NOT NULL DEFAULT false,
"created_at" timestamptz(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" timestamptz(6) NOT NULL DEFAULT CURRENT_TIMESTAMP
)
;
tyt2y3 commented
Thanks, but I mean how the SeaORM entity file look like?