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
When generating a model, the created file (e.g., src/models/persons.rs) is missing public reexports for ActiveModel and Model. Only Entity is publicly exported.
The default src/models/users.rs file, however, reexports everything through pub use super::_entities::users::{self, ActiveModel, Entity, Model};. This allows convenient (and clean) usage of these types in tests (see import section of tests/models/users.rs.
Tests for newly generated models (e.g., tests/models/persons.rs) need to use the full path to access the corresponding ActiveModel.
I do not consider this a bug - as the user can easily work around it - but unifying this would streamline the developer experience.
To Reproduce
Generate a new SaaS project
cargo loco generate scaffold persons uuid:uuid first_name:string! last_name:string! --api
Import section of tests/models/persons.rs and src/controllers/persons.rs is not ideal.
Expected Behavior
src/models/persons.rs should look like this:
pubusesuper::_entities::persons::{ActiveModel,EntityasPersons,Model};use sea_orm::entity::prelude::*;implActiveModelBehaviorforActiveModel{// extend activemodel below (keep comment for generators)}
tests/models/persons then can use a clean and simple import like use foobar::models::persons::{self, Persons};
Environment:
loco-cli 0.12.0
rustc 1.82.0 (f6e511eec 2024-10-15) with target stable-x86_64-unknown-linux-gnu (default)
Additional Context
None
The text was updated successfully, but these errors were encountered:
Description
When generating a model, the created file (e.g.,
src/models/persons.rs
) is missing public reexports forActiveModel
andModel
. OnlyEntity
is publicly exported.The default
src/models/users.rs
file, however, reexports everything throughpub use super::_entities::users::{self, ActiveModel, Entity, Model};
. This allows convenient (and clean) usage of these types in tests (see import section oftests/models/users.rs
.Tests for newly generated models (e.g.,
tests/models/persons.rs
) need to use the full path to access the correspondingActiveModel
.I do not consider this a bug - as the user can easily work around it - but unifying this would streamline the developer experience.
To Reproduce
cargo loco generate scaffold persons uuid:uuid first_name:string! last_name:string! --api
tests/models/persons.rs
andsrc/controllers/persons.rs
is not ideal.Expected Behavior
src/models/persons.rs
should look like this:tests/models/persons
then can use a clean and simple import likeuse foobar::models::persons::{self, Persons};
Environment:
Additional Context
None
The text was updated successfully, but these errors were encountered: