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.
post by NOLO on Jul 4
1 month later
post by johnny on Aug 5
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;
});
post by johnny on Aug 8
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
New & Unread Topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Using `unsetPagination()` but limit is still applied |
|
3 | 618 | Apr 12 |
| [RESOLVED] Error in “validate.php” in the “_get_language_mapping()” function |
|
10 | 1.9k | Mar 31 |
| Custom validation functions |
|
0 | 727 | Jan 22 |
| Function fieldType with parameter ‘multiselect_searchable’. and groupFields |
|
1 | 542 | Apr 9 |
| Change configuration |
|
0 | 432 | Jun 17 |