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

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1161
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2020-12-31 14:28

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

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1161
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2021-01-02 09:53

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

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1161
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2021-01-02 10:00

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


Post Reply