Generator-jhipster: Useless entity JSON attribute: otherEntityRelationshipNameUndefined

Created on 9 Feb 2019  路  9Comments  路  Source: jhipster/generator-jhipster

After looking at the code from the entity generation process, I've noticed a potentially useless and exported attribute in the JSON: otherEntityRelationshipNameUndefined.
It's not used anywhere but in the gen/entity/index.js file.

This is just a warning, there doesn't seem to be any real issue about it for the moment, but this has to go in the next generator release. I'm willing to do a PR for this later today if nobody beats me to it first.

minor jhipster-internals

Most helpful comment

@PierreBesson It's certainly related, yes. It looks like an attempt to reduce code redundancy, and this doesn't happen in JCore because we've made it "redundant" for some relationship types for this kind of cases.
@pvliss if it's only needed in the kotlin blueprint, then there must be a better way to handle it (I don't have one right now, but I'll think of something)

I'm working on cleaning up relationships in JCore, so I'll see what I can do about that.

All 9 comments

It looks like a bug related to string concatenation with an undefined value. Maybe on this line : https://github.com/jhipster/generator-jhipster/blob/ba65282ee12f5a70129b0df02827487d51a7ae03/generators/generator-base-private.js#L919

@MathieuAA I introduced that attribute in https://github.com/jhipster/generator-jhipster/commit/a72c3c8c5f2688a264e83f968bda11f49012d532 and the reason was to always have the proper otherEntityRelationshipName defined as it is needed for the Kotlin blueprint. Other than that it is indeed useless. If I remember correctly the problem was that if otherEntityRelationshipName was not defined and given a default value then the code block guarded by the if at line 928 would not kick in in order to get the proper relationship name from the other part of the relationship. I am obiously no expert at the internals and there's probably a better way to handle it or even better from the jhipster-core?

@PierreBesson It's certainly related, yes. It looks like an attempt to reduce code redundancy, and this doesn't happen in JCore because we've made it "redundant" for some relationship types for this kind of cases.
@pvliss if it's only needed in the kotlin blueprint, then there must be a better way to handle it (I don't have one right now, but I'll think of something)

I'm working on cleaning up relationships in JCore, so I'll see what I can do about that.

if it's only needed in the kotlin blueprint, then there must be a better way to handle it (I don't have one right now, but I'll think of something)

I'm working on cleaning up relationships in JCore, so I'll see what I can do about that.

Thanks!!! Highly appreciated and once more I am sorry for the latest JDL import issues caused. Let me know if you need any help, testing, etc.

Don't worry, failing by trying is not an issue: quite the opposite. So I think you shouldn't be sorry about anything :)

Thanks, you are too kind!!! I should have added more tests to begin with...

But another lesson learned, I guess :smile:

I remember it was recently fixed.
Can you confirm @pvliss ? In this case, can we close this ticket ?

The problem was in properly detecting missing otherEntityRelationshipName attribute.

JHipster Core has been fixed to always generate it in https://github.com/jhipster/jhipster-core/commit/f6b62e4e64d1aa30672fcdc37606cc0494306599 and https://github.com/jhipster/jhipster-core/commit/06ab8871f76dccc3d274a21f61af47882bef7f3a.

We can either delete the attribute using delete relationship.otherEntityRelationshipNameUndefined; or remove it completely but then I will also have to go through all the existing entity files used for the integrations tests and append any missing attributes.

I believe the 2nd option is the best but will need some time to get to it :) Probably within the next couple of days.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sdoxsee picture sdoxsee  路  4Comments

trajakovic picture trajakovic  路  4Comments

Steven-Garcia picture Steven-Garcia  路  3Comments

pascalgrimaud picture pascalgrimaud  路  4Comments

frantzynicolas picture frantzynicolas  路  3Comments