Skip to content

Bug report: Important bug in is_unique with DBGroup different than defined in $defaultGroup #1326

Description

@nowackipawel

My database config is:


public $defaultGroup = 'defaultZT';

public $defaultZT = ['my old database credentials'];

public $defaultNEW = ['my new database credentials'];


and simple model class...

class AdminGroupModel extends \CodeIgniter\Model
{
	protected $DBGroup 		= 'defaultNEW';
	protected $table 		= 't_admin_group';
	protected $primaryKey 	= 'agr_identifier';
	protected $returnType 	= 'App\Entities\Admin\AdminGroup';

	protected $allowedFields = [
		'agr_identifier',
		'agr_description'
	];

	protected $validationRules = [
		'agr_identifier' 	=> 'required|min_length[1]|max_length[16]|regex_match[/[0-9a-zA-Z]{1,16}/]|is_unique[t_admin_group.agr_identifier,agr_identifier,{agr_identifier}]',
		'agr_description' 	=> 'required|max_length[512]',
	];
}


When I am trying to save (new \AdminGroupModel)->save($entity); i get an exception:

mysqli_sql_exception #1146
Table 'myolddatabasename.t_admin_group' doesn't exist

which obviously means it tried to connect my old database.... i noticed that validation rule is_unique causes this exception.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions