Open smartcitydevops opened 6 years ago
Related with: https://github.com/telefonicaid/fiware-cygnus/pull/1413
Possible fix: use Varchar in that type
Possible fix long tail: check configuration flag before use ""
@smartcitydevops could you provide us the database schema (SQL> describe table_name) ?
mysql> desc mtc_snincidences ;
+-----------------------+---------------+------+-----+-------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+---------------+------+-----+-------------------+-------+
| incidenceCode | varchar(255) | NO | PRI | NA | |
| ID | varchar(50) | NO | | NA | |
| category | varchar(255) | YES | | NULL | |
| subject | varchar(1000) | YES | | NULL | |
| jurisdiction | varchar(50) | YES | | NULL | |
| priority | tinyint(4) | YES | | NULL | |
| latitude | decimal(11,8) | YES | | NULL | |
| longitude | decimal(11,8) | YES | | NULL | |
| scheduled_datetime | datetime | YES | | NULL | |
| status | varchar(10) | YES | | NULL | |
| status_datetime | datetime | YES | | NULL | |
| recvTime | timestamp | NO | PRI | CURRENT_TIMESTAMP | |
| fiwareServicePath | varchar(255) | YES | | NULL | |
| entityId | varchar(255) | YES | | NULL | |
| entityType | varchar(255) | YES | | NULL | |
| incidenceCode_md | varchar(255) | YES | | NULL | |
| ID_md | varchar(255) | YES | | NULL | |
| category_md | varchar(255) | YES | | NULL | |
| subject_md | varchar(1000) | YES | | NULL | |
| jurisdiction_md | varchar(255) | YES | | NULL | |
| priority_md | varchar(255) | YES | | NULL | |
| latitude_md | varchar(255) | YES | | NULL | |
| longitude_md | varchar(255) | YES | | NULL | |
| scheduled_datetime_md | varchar(255) | YES | | NULL | |
| status_md | varchar(255) | YES | | NULL | |
| status_datetime_md | varchar(255) | YES | | NULL | |
+-----------------------+---------------+------+-----+-------------------+-------+
The problem is related with '' data tried to be inserted in the scheduled_datetime column. Its value can be NULL, but not '' because this is a datetime column
@smartcitydevops There's no way Cygnus knows mysql column types before sending insert statements to decide whether to send "" or null.
Have you tryed adding a trigger to your database table? I mean, something like: mtc_snincidences_before_insert
BEGIN
if new.scheduled_datetime='' then
set new.scheduled_datetime= NULL;
end if;
if new.status_datetime='' then
set new.status_datetime= NULL;
end if;
END
We have found several cygnus traces, with this kind of message as an example:
The previous related message is this one:
There is a "scheduled_datetime" value for the first register to be inserted, but not for the second register. In fact, cygnus places an empty '' value for this column in the second register. The type for the "scheduled_datetime" column in "sys_snincidences" table is "datetime".
Could it be posible to avoid the change of the type of the table?