Update scrubValues method to make instants out of DateTimes - fixes update actions in javalin apps

This commit is contained in:
2022-10-03 10:40:45 -05:00
parent 3f84271a36
commit 21cd07b2df
2 changed files with 23 additions and 0 deletions

View File

@ -125,6 +125,10 @@ public abstract class AbstractRDBMSAction implements QActionInterface
{ {
value = ValueUtils.getValueAsLocalDate(value); value = ValueUtils.getValueAsLocalDate(value);
} }
else if(field.getType().equals(QFieldType.DATE_TIME) && value instanceof String)
{
value = ValueUtils.getValueAsInstant(value);
}
else if(field.getType().equals(QFieldType.DECIMAL) && value instanceof String) else if(field.getType().equals(QFieldType.DECIMAL) && value instanceof String)
{ {
value = ValueUtils.getValueAsBigDecimal(value); value = ValueUtils.getValueAsBigDecimal(value);

View File

@ -327,6 +327,25 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
/*******************************************************************************
** This situation - fails in a real mysql, but not in h2... anyway, because mysql
** didn't want to convert the date-time string format to a date-time.
*******************************************************************************/
@Test
void testDateTimesCanBeModifiedFromIsoStrings() throws Exception
{
UpdateInput updateInput = initUpdateRequest();
List<QRecord> records = new ArrayList<>();
records.add(new QRecord().withTableName("person")
.withValue("id", 1)
.withValue("createDate", "2022-10-03T10:29:35Z")
.withValue("firstName", "Johnny Updated"));
updateInput.setRecords(records);
new RDBMSUpdateAction().execute(updateInput);
}
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/