-
Notifications
You must be signed in to change notification settings - Fork 1.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
is_unique
is not considering the db prefix in checking for unique values in db
#3741
Comments
Are you changing the |
This groups I'm referring is the groups table. Not the db group connection. And I'm using the default db connection here. |
Ok, now I get it. You are setting rule like this:
but for
When you set this last parameter |
Ok. So that's how it is. Honestly, I copied this validation rule from myth/auth's |
Yes, it would be applied for both but in In general, now it is possible to change the rules on the fly, I think. |
Thanks for the enlightenment. |
Direction
I am testing a model where I've set the
unique
constraint on the migration file, and settingis_unique
check on the name field. I am using SQLite3 as the test db driver.Describe the bug
Migration
Model validation rules
I am developing a personal module and thus using the default
test
group of CI4 which uses sqlite3 anddb_
as db prefix.In my test case I have already seeded the groups table with
['name' => 'Admin', 'description' => 'Users with high powers']
. Now, I am purposely inserting a new record with the new record's name to be the sameAdmin
value. I am expecting the insert operation to be returningfalse
as I believe this will fail validation, but instead got an ErrorException (SQLite3::exec(): UNIQUE constraint failed: db_groups.name
). This means it passed validation and proceeded with the insert, which should not be the case.If this is useful, the groups name is actually dynamic and can be set through a config file. But basically the value is default to
groups
.CodeIgniter 4 version
develop
Affected module(s)
Validation
Context
The text was updated successfully, but these errors were encountered: