Skip to content

fix(CMDBSource): getFieldSpec returns NULL as a string#902

Open
Hipska wants to merge 2 commits intoCombodo:developfrom
Super-Visions:fix/cmdbsource/field_spec
Open

fix(CMDBSource): getFieldSpec returns NULL as a string#902
Hipska wants to merge 2 commits intoCombodo:developfrom
Super-Visions:fix/cmdbsource/field_spec

Conversation

@Hipska
Copy link
Copy Markdown
Contributor

@Hipska Hipska commented May 4, 2026

Base information

Question Answer
Related to a SourceForge thread / Another PR / A GitHub Issue / Combodo ticket? N/A
Type of change? Bug fix

Symptom

Not able to use ModuleInstallerAPI::MoveColumnInDB when the destination field is not yet present and it is a nullable integer, date, datetime.

Module xxxx : error when calling module installer class xxxx for BeforeDatabaseCreation handler: ModulelId = xxxx, ModuleInstallerClass = xxxx, ModuleInstallerHandler = BeforeDatabaseCreation, ExceptionClass = MySQLException, ExceptionMessage = Failed to issue SQL query: query = ALTER TABLE `ticket` ADD `resolution_date` datetime DEFAULT 'NULL', mysql_errno = 1067, mysql_error = Invalid default value for 'resolution_date'

Reproduction procedure

  1. On iTop 3.2.2
  2. With PHP 8.3.20
  3. Add static::MoveColumnInDB('ticket_request', 'resolution_date', 'ticket', 'resolution_date'); to a installer class.
  4. Run setup
  5. Finally, see error as above.

Cause

The code in CMDBSource::getFieldSpec makes wrong assumptions.

Proposed solution

First add tests that prove some scenario's fail, then update the mentioned method to better handle NULL defaults.

Test results before change: CMDBSourceTest_testGetFieldSpec.html

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have tested all changes I made on an iTop instance
  • I have added a unit test, otherwise I have explained why I couldn't
  • Is the PR clear and detailed enough so anyone can understand without digging in the code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending review

Development

Successfully merging this pull request may close these issues.

2 participants