Importing a CSV with '--skip-nested-set-build' raises an error in 2.5.x
|Category:||Data model / ORM|
|Target version:||Release 2.6.0|
|Google Code Legacy ID:||Tested version:||2.5|
- Run the `csv:import` CLI task with the `--skip-nested-set-build` option set.
The LFT and RGT columns will trigger the error:
Unable to execute INSERT statement. [wrapped: SQLSTATE[HY000]: General error: 1364 Field 'lft' doesn't have a default value]
On a 16.04 system, or with STRICT_TRANS_TABLES off, the import will proceed normally and the LFT and RGT fields will be set with a value of 0.
If the database is changed so that NULL is allowed in this field, a further Propel error is generated implying there is an assumption in the code that the default value needs to be zero and not NULL:
wrapped: Could not build SQL for expression: information_object.LFT < NULL
This issue is triggered by the re-addition of STRICT_TRANS_TABLES to the sql_mode. Options to fix it:
1. Remove the NOT NULL clause or add a default value to the column (requires migration). See notes above regarding default value.
2. Remove STRICT_TRANS_TABLES from sql_mode (less secure database and requires documentation and deploy changes).
3. Make sure LFT and RGT are not NULL on save of hierarchical objects. This could be limited to those objects that can be imported via CSV with a 'skip-nested-set' option, but it would be best to fix any other affected tables.