-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Unique validation rule needs to check if target attribute has previous validation errors #19407
Comments
There is nothing wrong with the rules themselves. You need to modify the
Without that addition empty strings will not be validated and you will pass not allowed value to your DB. |
It didn't help. Still can see that exception. Yes, there is nothing wrong with the rules themselves, I agree. But, can anyone has/had the same issue? Any thoughts? |
Hmm, I can see a slight problem indeed here, we need to correct this. When |
required
, default
and unique
rules
@bizley yeah, that's what I wanted to say. Thanks. |
hm...I'm check this case with MySQL8 and |
PostgreSQL 12.x |
@samdark Example:
Would previously create these errors:
But now it only creates one of them:
Not sure if worth fixing, but maybe might be worth noting in the CHANGELOG? |
Hm, yes, probably you are right, although it was 1 year ago. Do you time to add PR with that changelog mention for this version? |
The `unique` and `exists` validators behave slightly different since 2.0.46 when used on multiple/combined attributes. See: yiisoft#19407 (comment)
The `unique` and `exists` validators behave slightly different since 2.0.46 (issue yiisoft#19407) when used on multiple/combined attributes. See: yiisoft#19407 (comment)
The `unique` and `exists` validators behave slightly different since 2.0.46 (issue #19407) when used on multiple/combined attributes. See: #19407 (comment)
The `unique` and `exists` validators behave slightly different since 2.0.46 (issue #19407) when used on multiple/combined attributes. See: yiisoft/yii2#19407 (comment)
What steps will reproduce the problem?
claim
tablemedication
tableclaim_medication
Generated rules in the
ClaimMedication
model:ClaimMedication
modelWhat is the expected result?
Still expecting a single error on case 3:
Medication ID cannot be blank.
What do you get instead?
Database exception on case 3 (i.e.
unique
rule in action):Additional info
IMPORTANT: If I swap the order of the rules
required
&default
, then everything works as expected. But this change may affect of other models. The problem occurs precisely when there is more than one attribute in the ruleunique
.The text was updated successfully, but these errors were encountered: