IDEMPIERE-3662 Error when inserting PO with a LOB mandatory field

This commit is contained in:
Carlos Ruiz 2018-03-20 18:18:07 -03:00
parent 75d8fd5ea6
commit 193b7cae19
1 changed files with 23 additions and 3 deletions

View File

@ -2846,6 +2846,7 @@ public abstract class PO
if (DisplayType.isLOB(dt))
{
lobAdd (value, i, dt);
if (!p_info.isColumnMandatory(i))
continue;
}
@ -2885,7 +2886,16 @@ public abstract class PO
else if (c == String.class)
sqlValues.append (encrypt(i,DB.TO_STRING ((String)value)));
else if (DisplayType.isLOB(dt))
sqlValues.append("null"); // no db dependent stuff here
{
if (p_info.isColumnMandatory(i))
{
sqlValues.append("''"); // no db dependent stuff here -- at this point value is known to be not null
}
else
{
sqlValues.append("null");
}
}
else
sqlValues.append (saveNewSpecial (value, i));
}
@ -2909,9 +2919,19 @@ public abstract class PO
sqlValues.append("?");
if (DisplayType.isLOB(dt))
{
if (p_info.isColumnMandatory(i))
{
if (dt == DisplayType.Binary)
params.add(new byte[] {0}); // -- at this point value is known to be not null
else
params.add(""); // -- at this point value is known to be not null
}
else
{
params.add(null);
}
}
else if (value == null || value.equals (Null.NULL))
{
params.add(null);