Page 1 of 1

5.92 fatal error: lookup - when choosing empty (to remove) value fails update

Posted: 2020-12-31 14:28
by onoehring
Hi,

I am having a table_A (with PK integer, autoincrement) and table_B.
In table_B I have a lookup from table_A - so in the corresponding field of table_B an integer is expected.
When I create a new record in table_B everything is fine, even when I do not choose anything from the lookup (coming from table_A).
When I edit an existing value in table_B and want to remove the value from the lookup by choosing the empty entry on top the update fails when I press save:

Code: Select all

Incorrect integer value: '{empty_value}' for column 'ID_something_FK' at row 1
SQL-Anfrage:
UPDATE `sometable` SET `xx`='c2', `yy`='c2', `ID_something_FK`='{empty_value}' WHERE `ID`='203'
As you can see, {empty_value} is trying to be set into the integer field.

Can someone confirm this error please? Thanks

Olaf

Re: 5.92 fatal error: lookup - when choosing empty (to remove) value fails update

Posted: 2021-01-02 09:53
by onoehring
Hi,

I checked if the field definitions are correct (Admin area -> view/rebuild fields) and they are a perfect match between AG and MySQL.

I can reproduce the error.

Olaf

Re: 5.92 fatal error: lookup - when choosing empty (to remove) value fails update

Posted: 2021-01-02 10:00
by onoehring
Hi,

quick fix:
use the /hooks/tablename.php -> before_update hook to check for the value, and if it contains {empty_value} simply set it to NULL. Example:

Code: Select all

if ($data['yourfield'] == '{empty_value}'){
	$data['yourfield'] = NULL;
}
Olaf

Re: 5.92 fatal error: lookup - when choosing empty (to remove) value fails update

Posted: 2021-02-23 16:54
by onoehring
Hi,

the error still exists in 5.94 and is really annoying.

Olaf