New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entity generation fails if model-extra-attributes
include a comma surrounded by parentheses
#2063
Comments
naskya
changed the title
Entity generation fails if model-extra-attributes includes a comma
Entity generation fails if model-extra-attributes includes a comma surrounded by parentheses
Jan 14, 2024
naskya
changed the title
Entity generation fails if model-extra-attributes includes a comma surrounded by parentheses
Entity generation fails if Jan 14, 2024
model-extra-attributes
includes a comma surrounded by parentheses
naskya
changed the title
Entity generation fails if
Entity generation fails if Jan 14, 2024
model-extra-attributes
includes a comma surrounded by parenthesesmodel-extra-attributes
include a comma surrounded by parentheses
I also encountered the same problem sea-orm-cli generate entity -o entity/src -l -u postgres://postgres:postgres@localhost:22732/postgres
--with-serde both
--model-extra-attributes='graphql(concrete(name = "Favorite",params()))'
--model-extra-derives async_graphql::SimpleObject result
When I remove the comma before params, it can work properlyHowever, there are still spaces in front, which is not very aesthetically pleasing //! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.14
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(
Clone,
Debug,
PartialEq,
DeriveEntityModel,
Eq,
Serialize,
Deserialize,
async_graphql :: SimpleObject,
)]
#[sea_orm(table_name = "favorite")]
#[graphql(concrete(name = "Favorite"params()))]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub user_id: i32,
#[sea_orm(primary_key, auto_increment = false)]
pub action_id: i32,
pub create_time: Option<DateTime>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::actions::Entity",
from = "Column::ActionId",
to = "super::actions::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Actions,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
User,
}
impl Related<super::actions::Entity> for Entity {
fn to() -> RelationDef {
Relation::Actions.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {} |
Removing the comma also doesn't allow the generated code to be compiled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
We can't seem to pass a string containing a comma surrounded by parentheses as
model-extra-attributes
in sea-orm-cli. This becomes a problem when you want to passcfg_attr(predicate, attribute)
, for instance.Steps to Reproduce
Expected Behavior
Since the following does work and produces
Model
s with#[test(a)]
, I guesstest(a, b)
should also work.Actual Behavior
Reproduces How Often
This is always reproducible.
Workarounds
There's no workaround as far as I'm aware (except manual string processing for generated entities)
Reproducible Example
Versions
The text was updated successfully, but these errors were encountered: