-
Notifications
You must be signed in to change notification settings - Fork 8
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
Missing field rewrite OneToMany relation targets #1181
Comments
Hello @christian-mibex, Sorry for the late response. We gonna have a look at this next week.
We will start by reproducting your issue and then have a closer look on how it can be resolved. Kind regards, |
No worries, thanks for having a look! What is then the proposed solution to migrate from express-sequelize (camelCase in code & forestadmin, but snake_case in database) to the nodejs agent without reworking the UI? Best regards |
Hello @christian-mibex, I've looked at your project Mibex_CRM (that's the one you're trying to migrate to the agent Node.js, am I right?). For example, looking at our data you have a collection contactComments with a field If you have any more question about the migration I invite you to create a ticket on our community forum. We have a dedicated team that will be able to respond to you. 🙏 For your initiale issue, we will try to reproduce it but we are having a team building right now so it could take a few days to give you a proper explanation/fix. Kind regards, |
Hello @christian-mibex, We did release a small enhancement that return you clear message of the usable fields inside the customisation. Let us know if it's clearer to you. Kind regards, |
Hi Let's exclude the migration discussion for now. I think the problem is different.
In my opinion this is a clear bug. By the way the renaming works fine for the
works perfectly, does the correct rewrites etc. It's just that the target field does not get the same treatment. I appreciate the improved error message! 👏 I will also post in the community about the migration issues. Thanks, |
Hey @christian-mibex,
How do you rename the field ?
Ok, this is an issue. You should have the right typings properly generated.
But why the target field should have an other name than Could you share your configuration so that I can have a better understanding? Just for the record, maybe the documentation is misleading. I do have a model in my DB with the following declaration.
And in the agent I can use it properly with the snake case naming (it's totally normal). Ok, I think I go your issue. You want to create iso So you need to rename field in this case. I will have a look at creating a plugin for you that allow to rename all collections fields from snake_case to camelCase..
We hope that it will help everyone. 🙏 Kind regards, |
Hello @christian-mibex, Thank you for your feedback. 🙏 You can use our new plugin to do the job for you. We also improve the documentation by explaining correctly how to resolve those fields naming issues. Kind regards, |
Hi @Thenkei Sorry for the late reply, the email slipped through. For completeness here are the answers to your questions: do you rename the field?We use the following code
typing.tsIndeed, the typings.ts should use the renamed fields. I did not look into the generation procedure but I guess it's built before the agent is customized. naming examples:I was not very clear, I wanted to point out that the schema generation does not work for the example in the initial post:
but it does work if there is no snake_case name involved like here:
your working exampleYes this works because you have not renamed the fields. We could do this as well, but that means we would need to rewrite all the UI customization. This mismatch between camelCase (in UI) and snake_case (in database) comes because we migrated from the sequelize-express-agent. The sequelize model was camelCase, but stored in the PostgreSQL DB in snake_case. Forestadmin only saw the camelCase schema. We built the UI based on that. Now we migrated to the nodejs-agent. This means the sequelize layer is gone, and the agent created the schema/typings directly from the DB with snake_case. To counter this, we introduced the field renamings. This worked quite well, with the main downside being the typings.ts, and the required snake_case use in the backend. Thanks for the plugin, I will try it out and will give feedback! Thanks |
Hi The new rename plugin does only rename the fields, right? So it's the same as our code did:
The problem with snake_case in the originKeyTarget is still not solved. Best regards |
Expected behavior
We migrated a while ago from the express-sequalize agent to the nodejs agent.
During that migration we wanted to keep the camelCase naming in the UI facing schema to avoid rework.
As suggested here we rename the fields and collections.
We expect the same behavior for added relations:
Actual behavior
The schema generation fails with the following stack trace
When I debug the code, I see that the relation in the schema generation code has the snake_case name for
originKeyTarget
which then results in anundefinded
field and brakes the schema generation with the stack trace above.Context
The text was updated successfully, but these errors were encountered: