You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an existing postgresql schema that I wish to "uplift" into loco. Using regular sea-orm-cli (without loco), I am able to successfully generate entities using the following command:
I can then compile and use the generated entities as expected.
To Reproduce
When I try to use cargo loco db entities instead of sea-orm-cli, the entities get generated. However, compilation fails with:
error[E0277]: the trait bound `organization::ActiveModel: sea_orm::ActiveModelBehavior` is not satisfied
--> src/models/_entities/organization.rs:6:35
|
6 |#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]| ^^^^^^^^^^^^^^^^^ the trait `sea_orm::ActiveModelBehavior` is not implemented for`organization::ActiveModel`|
= help: the following other types implement trait `sea_orm::ActiveModelBehavior`:
_entities::client::ActiveModel
and 46 others
note: required by a bound in`sea_orm::EntityTrait::ActiveModel`
-->~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sea-orm-1.1.1/src/entity/base_entity.rs:62:23
|
62 |type ActiveModel: ActiveModelBehavior<Entity = Self>;| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in`EntityTrait::ActiveModel`
= note: this error originates in the derive macro `sea_orm::prelude::DeriveEntity` (in Nightly builds, run with -Z macro-backtrace for more info)
To Reproduce
cargo install loco-cli
loco new --path loco --name test --db postgres --template saas --assets serverside
cd loco/test
Set config/development.yaml to point to a moderately complex postgres database that was not generated via loco
cargo loco db entities
cargo build
Expected Behavior
The entities get generated and cargo build succeeds.
Environment:
This is a fresh installation of loco==0.12.0 on MacOS 15.0.1 using rustc --version 1.81.0. I am using postgresql 15.x, and tried sea-orm-cli 1.0.1, 1.1.0, 1.1.1 (all work fine when used directly.)
Additional Context
Edit: the issue seems to be that cargo loco db entities skips certain models when generating models/mod.rs (see first comment below). There does not seem to be anything different between these models and the ones that are actually generated:
Original: I tried passing cargo loco db entities --with-serde both --serde-skip-deserializing-primary-key --expanded-format, but received an argument --with-serde not recognized error.
Those arguments seem to be required for my sea-orm-cli entities to work. Is there a way to pass them or configure cargo loco db entities to use them?
The text was updated successfully, but these errors were encountered:
It looks like cargo loco db entities failed to add a number of generated entities to src/models/mod.rs. Adding them to mod.rs manually makes it compile.
I guess the bug here lies in why they are not being added to mod.rs.
Hi, I believe this is because we're augmenting the generated entities right after using seaorm-cli to generate. But something in your schema is turning up as unexpected.
See here: https://github.com/loco-rs/loco/blob/master/src/db.rs#L340
I'm wondering if you can share that schema so we can repro on it?
Description
I have an existing postgresql schema that I wish to "uplift" into loco. Using regular sea-orm-cli (without loco), I am able to successfully generate entities using the following command:
sea-orm-cli generate entity \ --output-dir src/models/_entities \ --database-url "${database_url}" \ --with-serde both \ --serde-skip-deserializing-primary-key \ --expanded-format
I can then compile and use the generated entities as expected.
To Reproduce
When I try to use
cargo loco db entities
instead ofsea-orm-cli
, the entities get generated. However, compilation fails with:To Reproduce
cargo install loco-cli
loco new --path loco --name test --db postgres --template saas --assets serverside
cd loco/test
config/development.yaml
to point to a moderately complex postgres database that was not generated via lococargo loco db entities
cargo build
Expected Behavior
The entities get generated and
cargo build
succeeds.Environment:
This is a fresh installation of
loco==0.12.0
on MacOS 15.0.1 usingrustc --version
1.81.0. I am using postgresql 15.x, and tried sea-orm-cli 1.0.1, 1.1.0, 1.1.1 (all work fine when used directly.)Additional Context
Edit: the issue seems to be that
cargo loco db entities
skips certain models when generatingmodels/mod.rs
(see first comment below). There does not seem to be anything different between these models and the ones that are actually generated:Original:
I tried passingcargo loco db entities --with-serde both --serde-skip-deserializing-primary-key --expanded-format
, but received anargument --with-serde not recognized
error.Those arguments seem to be required for mysea-orm-cli
entities to work. Is there a way to pass them or configurecargo loco db entities
to use them?The text was updated successfully, but these errors were encountered: