SeaQL / SeaQL/sea-orm

Generate doesn't handle columns starting with numbers

Open
#2,685 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:code-gen
Dominant language
Rust
Stars
9.9k
Forks
734
Avg merge
6h 36m
Merged PRs (30d)
8

Description

Description

Heya, trying to start a project with seaorm using sea-orm-cli generate entity but unfortunately the db I'm inheriting has columns that start with numbers and it panics on them.

First brought up on Discord and was recommended to make a github issue https://discord.com/channels/873880840487206962/1402911922025795624.

Steps to Reproduce

Run sea-orm-cli generate entity on a database with a table column starting with a number.

Expected Behavior

Handles columns that aren't valid rust idents.

Actual Behavior
    > Column `2xl_16`: Option<Decimal>
thread 'main' panicked at /Users/choc/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/quote-1.0.40/src/runtime.rs:444:9:
"2xl_16" is not a valid Ident

Versions

sea-orm-cli 1.1.14

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

Start with the sea-orm-cli generate entity entry point and reproduce the panic using a database column named 2xl_16. Trace how generated Rust identifiers are handled for invalid column names; done means entity generation completes without panicking and supports columns that are not valid Rust identifiers.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.