mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
QQQ-14 update createDate, modifyDate to default to current
This commit is contained in:
@ -25,6 +25,7 @@ package com.kingsrook.qqq.backend.module.rdbms.actions;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.OffsetDateTime;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.AbstractQTableRequest;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.QFieldMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.QFieldType;
|
||||
@ -102,6 +103,14 @@ public abstract class AbstractRDBMSAction
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// todo - let this come from something in the field //
|
||||
//////////////////////////////////////////////////////
|
||||
if(value == null && (field.getName().equals("createDate") || field.getName().equals("modifyDate")))
|
||||
{
|
||||
value = OffsetDateTime.now();
|
||||
}
|
||||
|
||||
return (value);
|
||||
}
|
||||
}
|
||||
|
@ -652,6 +652,12 @@ public class QueryManager
|
||||
statement.setTimestamp(index, timestamp);
|
||||
return (1);
|
||||
}
|
||||
else if(value instanceof OffsetDateTime)
|
||||
{
|
||||
Timestamp timestamp = new Timestamp(((OffsetDateTime) value).toEpochSecond() * MS_PER_SEC);
|
||||
statement.setTimestamp(index, timestamp);
|
||||
return (1);
|
||||
}
|
||||
else if(value instanceof LocalDateTime)
|
||||
{
|
||||
Timestamp timestamp = new Timestamp(((LocalDateTime) value).toEpochSecond(ZoneOffset.UTC) * MS_PER_SEC);
|
||||
|
@ -74,6 +74,7 @@ public class RDBMSInsertActionTest extends RDBMSActionTest
|
||||
rowsFound++;
|
||||
assertEquals(6, rs.getInt("id"));
|
||||
assertEquals("James", rs.getString("first_name"));
|
||||
assertNotNull(rs.getString("create_date"));
|
||||
}
|
||||
assertEquals(1, rowsFound);
|
||||
}));
|
||||
|
Reference in New Issue
Block a user