Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field name 'is_2fa' converted to 'is2fa' during insertion in SeaORM #2114

Open
limitcool opened this issue Feb 20, 2024 · 3 comments
Open

Field name 'is_2fa' converted to 'is2fa' during insertion in SeaORM #2114

limitcool opened this issue Feb 20, 2024 · 3 comments

Comments

@limitcool
Copy link

Description

When generating entity with SeaORM, the insertion statement unexpectedly transforms the field name "is_2fa" into "is2fa".

Steps to Reproduce

  1. 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?;
  1. 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
Copy link
Member

tyt2y3 commented Mar 2, 2024

What is your Entity definition?

@limitcool
Copy link
Author

limitcool commented Mar 2, 2024

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
Copy link
Member

tyt2y3 commented Mar 2, 2024

Thanks, but I mean how the SeaORM entity file look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants