PHP Version
8.1
CodeIgniter4 Version
4.2.2
CodeIgniter4 Installation Method
Composer (as dependency to an existing project)
Which operating systems have you tested for this bug?
macOS, Linux
Which server did you use?
fpm-fcgi
Database
MariaDB 10.8
What happened?
In the new minor version of CI Database/Forge class has now:
// If table exists lets stop here
if ($ifNotExists === true && $this->db->tableExists($table)) {
$this->reset();
return true;
}
Let's focus on $this->db->tableExists($table) if flag $ifNotExists is true
Will give a real example of issue:
For tests I have a migration which fully drop current database and restore it from the provided SQL file. I'm doing it with direct db connection ($this->db->mysqli) using multi_query(). Then I need to create a migration table in order for the migration system to work. I'm doing it with Forge class, because it's a framework technical table and should not be included into project SQL scheme.
Steps to Reproduce
In the migration file:
- drop db
- add db
- then try to create migration table if it doesn't exist (to prevent possible error on failing)
- table is not created, because the check
$this->db->tableExists($table) uses cache
This example only applies to my case, but let's assume the following:
Just drop any table with query method and then try to restore it via forge class
Expected Output
Forge class shouldn't rely on cache, or should be highlighted in the documentation that Forge class relies on the cache in its work and should not be used (or it is necessary to clear the cache) when working with direct querying, not through the builder
Anything else?
Ref #6249
PHP Version
8.1
CodeIgniter4 Version
4.2.2
CodeIgniter4 Installation Method
Composer (as dependency to an existing project)
Which operating systems have you tested for this bug?
macOS, Linux
Which server did you use?
fpm-fcgi
Database
MariaDB 10.8
What happened?
In the new minor version of CI Database/Forge class has now:
Let's focus on
$this->db->tableExists($table)if flag$ifNotExistsis trueWill give a real example of issue:
For tests I have a migration which fully drop current database and restore it from the provided SQL file. I'm doing it with direct db connection (
$this->db->mysqli) usingmulti_query(). Then I need to create a migration table in order for the migration system to work. I'm doing it with Forge class, because it's a framework technical table and should not be included into project SQL scheme.Steps to Reproduce
In the migration file:
$this->db->tableExists($table)uses cacheThis example only applies to my case, but let's assume the following:
Just drop any table with
querymethod and then try to restore it via forge classExpected Output
Forge class shouldn't rely on cache, or should be highlighted in the documentation that Forge class relies on the cache in its work and should not be used (or it is necessary to clear the cache) when working with direct querying, not through the builder
Anything else?
Ref #6249