Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.2.0-ALPHA1
-
Fix Version/s: 1.0.13, 1.1.5, 1.2.0-ALPHA3
-
Component/s: Import/Export
-
Labels:None
Description
When importing a db table as a model, we see the following for a boolean field:
$this->hasColumn('is_blocked', 'boolean', 1, array( 'type' => 'boolean', 'length' => 1, 'fixed' => false, 'unsigned' => false, 'notnull' => true, 'default' => 'false', // <----- this field not 0, 1 or a boolean, but a string literal linstead 'primary' => false, ));
Creating an object and immediately saving it results in two validation errors for this field:
1. The field is not boolean, but string
2. The field is not length 1, but length 5 (string "false")
I applied the following patch to the listTableColumns() function:
elseif (preg_match("/^'(.*)'::character varying$/", $description['default'], $matches)) { $description['default'] = $matches[1]; } + elseif ($description['type'] == 'boolean') { + if ($description['default'] === 'true') { + $description['default'] = true; + } elseif ($description['default'] === 'false') { + $description['default'] = false; + } + } $columns[$val['field']] = $description;
This makes the import work as expected for us.