PHP Version
8.1
CodeIgniter4 Version
4.1.5
CodeIgniter4 Installation Method
Git
Which operating systems have you tested for this bug?
Linux
Which server did you use?
cli
Database
MariaDB 10.1
What happened?
The data type selected is different from the DB field type.
For example, if you use a migrate file to define a field type as INTEGER or FLOAT, and then execute php spark migrate on the database to create a table, the data type returned using Query Builder will be different from the type initially set.
Steps to Reproduce
- Use Migration make a migrate file.
- addField into mugrate file.
$this->forge->addField([
'is_string' => [
'type' => 'VARCHAR',
'constraint' => 30,
'comment' => "is_string"
],
'is_integer' => [
'type' => 'INT',
'constraint' => 30,
'comment' => "is_integer"
],
'is_float' => [
'type' => 'FLOAT',
'comment' => "is_float"
],
]);
$this->forge->addKey('is_string', true);
$this->forge->createTable('CastTable');
- Use db query in Controller to get data
$db = \Config\Database::connect();
$queryData = $db->table('CastTable')->get()->getResult();
var_dump($queryData);
4.Get data of the wrong type
array(1) {
[0]=>
object(stdClass)#57 (3) {
["is_string"]=>
string(17) "Hi CodeIgniter4 !"
["is_integer"]=>
string(3) "999"
["is_float"]=>
string(5) "9.999"
}
}
Expected Output
array(1) {
[0]=>
object(stdClass)#57 (3) {
["is_string"]=>
string(17) "Hi CodeIgniter4 !"
["is_integer"]=>
int(999)
["is_float"]=>
float(9.999)
}
}
Anything else?
No response
PHP Version
8.1
CodeIgniter4 Version
4.1.5
CodeIgniter4 Installation Method
Git
Which operating systems have you tested for this bug?
Linux
Which server did you use?
cli
Database
MariaDB 10.1
What happened?
The data type selected is different from the DB field type.
For example, if you use a migrate file to define a field type as INTEGER or FLOAT, and then execute
php spark migrateon the database to create a table, the data type returned using Query Builder will be different from the type initially set.Steps to Reproduce
4.Get data of the wrong type
Expected Output
Anything else?
No response