Cannot add a column with spaces on the default value (Convert layer logging migration script)

Description

While testing IDEMPIERE-2981: Implement JSON Field typeClosed

Found that we cannot add a column with a default containing spaces when using postgresql non-native, this is, convert layer.

Even when using the native postgresql layer, when creating migration scripts the convert layer is applied, so it fails also if the Log Migration Script preference is enabled

Test case in https://test.idempiere.org/webui/

  • Log in as System Administrator role

  • Open the table Test and navigate to column Description - like in this URL

  • Change the Default Logic to 'Test default with spaces'

  • Enable user preference Log Migration Script and Save

  • Click the Synchronize Column button

  • Error → org.postgresql.util.PSQLException: Unterminated string literal started at position 81 in SQL INSERT INTO t_alter_column values('test','Description','VARCHAR(255)',null,''Test'). Expected char

The problem is in org.compiere.dbPort.Convert_PostgreSQL.convertDDL(String)

around line 1109 it tries to discover the default value based on the first word, before the first space, I think in case the default is surrounded by quotes it must take it until the next quote instead of space.

Environment

None

discovered while testing

Activity

Fixed

Details

Assignee

Reporter

Fix versions

Priority

Created September 7, 2024 at 9:33 AM
Updated November 1, 2024 at 7:30 PM
Resolved September 11, 2024 at 11:42 AM