balena-io / pinejs

Generate rest APIs from natural language models
Apache License 2.0
62 stars 10 forks source link

Fix getIdField using idField of intermediate translation #781

Closed otaviojacobi closed 1 week ago

otaviojacobi commented 2 months ago

getIdField tries to return the name of the id field in the database model (and not in any translated model) This turns out to be a problem when more than one layer of native translations are present for a given table as it tries to use the resource name of a given version on the final abstract sql model

This approach will use the actual translation (rather than the final one) in case the translated table exists, avoiding trying to find a non existent translation on the final model

Resolves: https://github.com/balena-io/pinejs/issues/794 Change-type: patch See: https://balena.zulipchat.com/#narrow/stream/345890-balena-io/topic/pinejs.20bump.20dependencies/near/455374721

thgreasi commented 2 weeks ago

I can confirm that this works w/ both oB & bC v7 changes w/o needing the $toResource toVersion->$resin workarounds :heart: See: https://github.com/balena-io/open-balena-api/pull/1684/files#diff-8c30cbe3a5e90e20f89a2916ad53db6a65d8b8afd746265c79ad0d17f78cafa0R91 See: https://github.com/balena-io/balena-api/pull/5120

otaviojacobi commented 2 weeks ago

I also confirmed it works with "current" mater: See: https://github.com/balena-io/open-balena-api/pull/1732 See: https://github.com/balena-io/balena-api/pull/5246

I think this is a solution, I am just not sure if it is the optimal one

thgreasi commented 2 weeks ago

I'm fine w/ this as is, but I would like Page to take a look to check it as well since I'm not that familiar w/ translations. The code makes sense as I read it, so pending Page to confirm that it is also indeed the correct way.