SeaQL / SeaQL/sea-orm

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

Open
#2,114 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-info
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

  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"] }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.