Defining a composite money column as nullable returns a different type:
// non-nullable column
val money: CompositeMoneyColumn<BigDecimal, CurrencyUnit, MonetaryAmount> = compositeMoney()
// actual nullable column
val nullableMoney: CompositeMoneyColumn<MonetaryAmount?> = compositeMoney().nullable()
// expected nullable column
val money: CompositeMoneyColumn<BigDecimal?, CurrencyUnit?, MonetaryAmount?> = compositeMoney().nullable()
The current setup works as long as the insert value is a composite Money value, as the individual columns will not be able to be resolved.
If the component values (BigDecimal and CurrencyUnit) are inserted individually into the component columns, it will only work for either a non-nullable column or a nullable column with a non-null value. This happens because each component column is correctly nullable, but not the actual composite expression itself, resulting in the error:
Can't set null value to non-nullable CompositeMoneyColumn column
This fix adds an overload so that compositeMoney().nullable() returns the expected type and adds the ability to modify the internal nullable property in BiCompositeColumns.
None of the current tests included inserts/updates that targeted the individual component columns, so this has been included too.
Defining a composite money column as nullable returns a different type:
The current setup works as long as the insert value is a composite
Money
value, as the individual columns will not be able to be resolved.If the component values (
BigDecimal
andCurrencyUnit
) are inserted individually into the component columns, it will only work for either a non-nullable column or a nullable column with a non-null value. This happens because each component column is correctly nullable, but not the actual composite expression itself, resulting in the error:This fix adds an overload so that
compositeMoney().nullable()
returns the expected type and adds the ability to modify the internalnullable
property inBiCompositeColumns
.None of the current tests included inserts/updates that targeted the individual component columns, so this has been included too.