-
Notifications
You must be signed in to change notification settings - Fork 100
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 foreign keys in validation rules #327
Conversation
Codecov Report
@@ Coverage Diff @@
## master #327 +/- ##
============================================
- Coverage 95.64% 95.63% -0.02%
+ Complexity 591 588 -3
============================================
Files 23 23
Lines 1884 1878 -6
============================================
- Hits 1802 1796 -6
Misses 82 82
Continue to review full report at Codecov.
|
We also have the |
generated for null schema
for not null schema
|
i think this change not related to |
probably you say bake should bake like :
|
Right now we don't generate any validators for foreign keys, and instead rely on the |
problem is not |
result of we should validate it in table:save() should be return
|
i think no, is not true |
Mentioned lines in core is invalid |
I think i found another problem in core that make conflict with this PR
I want to resolve not present field in core ,closing until that time |
Error will remove in setDirty after inline set |
Ok, I was under the impression you were having problems with nullable foreign keys. Not required foreign key columns. The code you linked to in ExistsIn cannot be removed as it will cause breakage in existing applications. It sounds like we should at least be adding the I'm not sure we need to also generate the unique validators when the foreign key columns also have SQL constraints though. The |
I want to fix it instead of removing for old programs or programs that not using bake |
I think you can merge this |
@saeideng Right now bake will start re-adding |
ping some of people not using foreign key constraints ,because cakephp handle it |
@markstory What shall we do here? |
{ | ||
$validator | ||
->integer('category_id') | ||
->allowEmpty('category_id', 'create'); |
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.
Is the difference with this implementation vs the old one that keys can be blank on create?
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 for null
able column validation is not necessary , but for not null
is important
we can remove validation when foreign key was $validator
->requirePresence('category_id', 'create')
->notEmpty('category_id');
//or
->notEmpty('category_id', 'create'); |
needs rebase. |
@saeideng Shall we finish this PR? |
Also refs cakephp/migrations#385 |
@saeideng Are u still interested in finishing this up? |
let me to check again whole changes in next few days |
@saeideng ping |
I think it is valid yet , but whole PR needs to re create with change on command class |
Refs cakephp/cakephp#10355 cc @markstory
Revert #62 cc @markstory
old issue #61 cc @lorenzo