When creating VARCHAR columns in PostgreSQL with a default value (for example, column_1 with a length of 1 and a default value of ‘N’), the error “Value too long for character varying 1” occurs. This happens because the default values are read in model.php; for that column, the value becomes 'N'::varchar. When attempting to save a new record (while omitting the value for column_1), the data array contains the value 'N'::varchar, triggering the error.
Hello @NOLO and sorry for the delay. I was able to reproduce it and I have it fixed for the next version. For now if this blocks you, please try to replace the value on insert with a callback. For example:
$crud->callbackBeforeInsert(function ($stateParameters) {
if (isset($stateParameters->data['column_1']) && $stateParameters->data['column_1'] === "'N':: varchar") {
$stateParameters->data['column_1'] = 'N';
}
return $stateParameters;
});
1 Like
Hello @NOLO ,
I am glad to inform you that this is now fixed in version 3.2.11 so no work-around is needed. In order to update to the latest version, please follow the instructions of the wizard: User's Page Login
In case you are still facing issues, please do let me know.
Regards
Johnny
1 Like