HaxeFoundation / record-macros

Macro-based ORM (object-relational mapping)
MIT License
49 stars 24 forks source link

Fix relKey auto-creation #48

Closed ConstNW closed 4 years ago

ConstNW commented 4 years ago

don't create field for relation if it already exists

jonasmalacofilho commented 4 years ago

Can I ask what's the use case?

ConstNW commented 4 years ago

manually declare relation key to use it value by own purposes

ConstNW commented 4 years ago

I see, but we should check that the existing field is compatible with what we need.

What it is for? I suppose If you manually defining relation key then you should care about everything related to it

jonasmalacofilho commented 4 years ago

I suppose If you manually defining relation key then you should care about everything related to it

If the collision is intentional, I can see your point. But the relKey is used by the generated getter and setter, and I imagine that if the user has chosen to use a @:relation, he still expects them to work.

And what about accidental collisions?

ConstNW commented 4 years ago

@jonasmalacofilho take a look on changes please

jonasmalacofilho commented 4 years ago

Looks good to me, and the tests pass (even though for some reason Travis has stopped updating the commit/PR status).

Thank you @ConstNW.

grepsuzette commented 3 years ago

Possible regression introduced with this PR, see https://github.com/HaxeFoundation/record-macros/issues/57

jonasmalacofilho commented 3 years ago

@emugel I think you're right.