-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Use the name of the table to create the relation #542
Conversation
The tests failed, but this is exactly the kind of thing PR should avoid:
This: getSupplier() hasOne Product Should be: getProduct() hasOne Product |
What if both relations are needed? |
Look, I'm not eliminating the relationship. Just renaming. Using the table name instead of the primary key. |
Tests should be fixed. |
@samdark Done! With updated tests, the proposal can become clearer. |
@samdark Is there any chance this change will be present in the next release? |
@bizley @terabytesoftw Could you please review? |
I think there should be a configuration option for this change for backwards compatibility. E.g. when used with https://github.com/schmunk42/yii2-giiant. |
I would not want to keep the old way. @schmunk42 could you check if this change is problematic with your package? |
One thing is, that the workflow with But another more important thing is, that if you have a table I'd not change this. At least not for yii2. |
Ok, I see. If we correct this in one case, the other one is broken. @thiagotalma could you make it configurable? |
Configuration in the module or on the gii screen? |
gii screen I think |
@thiagotalma There should be tests for both cases (original ones and the new one). |
Can anyone help me with the tests, please? |
You might need an additional param in your data provider:
And use it in your new use-cases in
The existing ones should be kept/reverted. |
I was thinking about this some more since I encountered a similar situation today. function ($foreignKey) {
// some custom base name determination
return $myCustomBaseName;
} So my proposal would be to make it indeed configurable as discussed above and add a third option.
|
Done! Thanks, @schmunk42 |
@thiagotalma You're welcome. LGTM now :) |
Thank you! |
Guys, it looks like there was a problem with the merge. |
Oh, indeed. @thiagotalma could you prepare another PR correcting this? |
Hello guys! What do you think about releasing the new version? I'm just waiting for these changes to move forward with my project. |
Use the real name of the table to create the relationship when there is a composite primary key.
Prevents the generation of random relationship names.
Turn this:
Into this: