yii2
yii2 copied to clipboard
Update UniqueValidator.php
| Q | A |
|---|---|
| Is bugfix? | ✔️ |
| New feature? | ❌ |
| Breaks BC? | ✔️/❌ |
| Fixed issues | #19407 |
I don't see how your solution is addressing the problem in any way.
@bizley your tests not correct:
1.when passed more than one attribute, then need check they together BEFORE call validateAttribute() because they using together to generate SQL i.e. error in ANY attribute can fail execution
2. you call validateAttribute() instead validateAttributes() i.e. skip check skipOnError and skipOnEmpty and it's fake test: https://github.com/yiisoft/yii2/pull/19409/files#diff-558153fc1165cfc96b7b9bef56fcf62d67f049ae2fec7165e77561040b9ce360R523
3. you not set required attributes property using in validateAttributes()
https://github.com/yiisoft/yii2/blob/14369f0a517efed333d69d44fc84eb8f4a5b1907/framework/validators/Validator.php#L248
4. you ignore property $targetClass i.e. you fix generate invalid query in case like this: [['foo', 'bar'], 'unique', 'targetClass' => Model::class, 'targetAttribute' => ['foo_id' => 'foo', 'bar_id' => 'bar']],
As I explained in details already in my fix attempt for this issue I stand behind my version.
Thank you for putting effort in the improvement of the Yii framework. We have reviewed your pull request.
In order for the framework and your solution to remain stable in the future, we have a unit test requirement in place. Therefore we can only accept your pull request if it is covered by unit tests.
Could you add these please?
Thanks!
P.S. If you have any questions about the creation of unit tests? Don't hesitate to ask for support. More information about unit tests
This is an automated comment, triggered by adding the label pr:request for unit tests.