Inside the data tabs, we have several collections who all work beside one.
When Forest admin try to retrieve the data, he makes an API call to my local url http://localhost:3000/forest/Product. This call trigger a function inside my back which execute a sql command containing an error. This error is due to “LEFT OUTER JOIN” on an non existing column. (we have something like “LEFT OUTER JOIN Clients on Clients.product_id = products.id”), here the product_id inside clients doesn’t exist.
For all of my others collections everything is fine, but not the products collection.
the web console log display an error 500 after calling a GET request on the url http://localhost:3000/forest/Product
the backend console display this error:
- Project name: AB Tracking
- Team name: Operations
- Environment name: development
- Agent type & version: forest admin for Rails env (version 7.7.2)
- Recent changes made on your end if any: I’ve seen and removed product_id in the Clients inside the forestadmin-schema.json
Moreover I’m using a docker container and after several tries I never could update the schema using the command forest schema:update. Note that the error was there before I tried to change the forestadmin-schema.json
Don’t hesitate to ask for deeper informations.
Hello @JuHue and welcome to our community !
I am sorry to hear that you have issues, our rails agent will generate the queries based on the model you have defined, removing the fields directly in the .forestadmin-schema.json will not help you. If you are confortable with it you can share the models of your Client and Products classes.
Hello Dogan, thanks for the response !
Im sharing my models with you.
This my Client model:
And this is my products model:
Does it help you ?
Yes thank you !
I noticed that you have set the relation “has_one” to your client from the Product model. Based on the rails documentation on associations when using a “has_one” association, the table “client” would be the one owning the association id. So the generated query does respect the type of association defined.
I don’t know how your database is structured, but if the association is owned by the “products” table via a “client_id”, a better fitting association would be “belongs_to” (here is the documentation).
Indeed, this was my error. Thank you very much
I am happy to have been able to help ! Feel free to create a new topic if you encounter issues.
I will mark this as solved.
Have a nice week-end !