-
Notifications
You must be signed in to change notification settings - Fork 102
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
Make sure custom relations work out with new alias strictness. #1015
Conversation
It actually works:
Maybe someone wants to add a test case for it? E.g. @luizcmarin ? |
Turns out there is already an existing test case that so far was already invalid (exception would have happened), and now working: |
@ADmad I found a way to make it work. |
correction due to the error shown below. Creating file C:\marin\www\GitHub\lixo\tests\TestCase\Model\Table\AnnouncementsTableTest.php Wrote `C:\marin\www\GitHub\lixo\tests\TestCase\Model\Table\AnnouncementsTableTest.php` Done One moment while associations are detected. 2024-11-26 10:24:32 warning: Undefined variable $className Trace: Bake\Command\ModelCommand->findBelongsTo() C:\marin\www\GitHub\trash\vendor\cakephp\bake\src\Command\ModelCommand.php, line 247 Bake\Command\ModelCommand->getAssociations() C:\marin\www\GitHub\trash\vendor\cakephp\bake\src\Command\ModelCommand.php, line 166 Bake\Command\ModelCommand->getTableContext() C:\marin\www\GitHub\trash\vendor\cakephp\bake\src\Command\ModelCommand.php, line 119 Bake\Command\ModelCommand->bake() C:\marin\www\GitHub\lixo\vendor\cakephp\bake\src\Command\ModelCommand.php, line 101 Bake\Command\ModelCommand->execute() C:\marin\www\GitHub\trash\vendor\cakephp\bake\src\Command\AllCommand.php, line 116 Bake\Command\AllCommand->execute() C:\marin\www\GitHub\trash\vendor\cakephp\cakephp\src\Console\BaseCommand.php, line 204 Cake\Console\BaseCommand->run() C:\marin\www\GitHub\trash\vendor\cakephp\cakephp\src\Console\CommandRunner.php, line 330 Cake\Console\CommandRunner->runCommand() C:\marin\www\GitHub\trash\vendor\cakephp\cakephp\src\Console\CommandRunner.php, line 168 Cake\Console\CommandRunner->run() C:\marin\www\GitHub\lixo\bin\cake.php, line 10 [main]
|
I created a small test with some tables where errors occur. You may want to take note of this inconvenience. |
I wonder if thats directly related to the issue here (was working before and now not) |
In fact, bake never finished generating the files due to this problem. This also happened with other tables. I isolated these attached tables for you to test, if you wish. But it happens with others too. Does this happen to you? I'll send you the full script, in case you want to try it. |
You need to actually share the commands you use For me both "bake all Countries" and then "bake all Users" works just fine now with the upgrade here. So whats the concrete command that breaks, and what have been generated before, or if manually adjusted, what does that file look like before running bake. Again: I am fairly certain this is outside the scope of this specific issue here, and should not block the relation fix for the current bug in the system. |
I do not rule out the possibility of errors here. Please, if everything is ok in your tests, continue. I will do new tests after updating. The command I use is simply: " bin\cake bake all --everything". Nothing more than that. |
I can partically reproduce it
This wrongly is a proposal_id, but should be something else at least to make clear this is from invoices table referenced, and also must always be different from the actual proposal_id since Proposals is their own table. |
Thank you very much for the tip. This means more work for me and less for you :) :(... |
Well, #1019 will make it easier for you once merged :) |
All good? Can we squash merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from the minor nitpick of function name.
Refs #1012
So basically 5.1 and the more strict relation-handling ("Association alias
Countries
is already set") kinda broke the non documented feature of custom relationship baking.Even though it was just baked wrongly with always the same Countries relation.
This PR adds the expected aliasing (back) ensuring there is no collision, and having the correct name in the process for most cases:
as example for
Countries
Users