SeaQL / SeaQL/sea-orm

sea-orm-cli hard codes schema

Open
#2,235 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

When using the sea-orm-cli like this:

sea-orm-cli generate entity -o entity/src/new \
	--lib \
	--with-copy-enums \
	--with-serde both \
	--date-time-crate time\
	-u postgresql://docker:root@localhost:5432/docker

Sea-orm generates something like this:

#[sea_orm(schema_name = "public", table_name = "account")]

Hard coded schema name is generally not a good idea as the user maybe want to use a different schema.
Also there is already the DATABASE_SCHEMA env var that would become obsolete.

Steps to Reproduce

  1. execute the command above
  2. see the hard coded schema
Expected Behavior

Just do not generate the schema like before.
Generate this instead:

#[sea_orm(table_name = "account")]
Actual Behavior

Generates this:

#[sea_orm(schema_name = "public", table_name = "account")]
Reproduces How Often

Every time

Workarounds

Just remove it afterwards

Reproducible Example

https://github.com/financrr/financrr-app/tree/main/backend

Versions

v1.0.0-rc.4

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 by running the sea-orm-cli generate entity command from the report against PostgreSQL and inspect the generated entity attribute. Trace the CLI's entity-generation path to find where schema_name = "public" is emitted. Done means generated entities use only table_name = "account" as shown in the expected behavior.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.