Fix PostgreSQL query for storing timestamps (#13745)
Fixes #13121 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
c9b9002b8e
commit
d3348327a9
|
@ -13,6 +13,7 @@
|
|||
package org.openhab.persistence.jdbc.internal.db;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
@ -167,6 +168,22 @@ public class JdbcPostgresqlDAO extends JdbcBaseDAO {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doStoreItemValue(Item item, State itemState, ItemVO vo, ZonedDateTime date) throws JdbcSQLException {
|
||||
ItemVO storedVO = storeItemValueProvider(item, itemState, vo);
|
||||
String sql = StringUtilsExt.replaceArrayMerge(sqlInsertItemValue,
|
||||
new String[] { "#tableName#", "#dbType#", "#tablePrimaryValue#" },
|
||||
new String[] { storedVO.getTableName(), storedVO.getDbType(), "?" });
|
||||
java.sql.Timestamp timestamp = new java.sql.Timestamp(date.toInstant().toEpochMilli());
|
||||
Object[] params = { timestamp, storedVO.getValue() };
|
||||
logger.debug("JDBC::doStoreItemValue sql={} timestamp={} value='{}'", sql, timestamp, storedVO.getValue());
|
||||
try {
|
||||
Yank.execute(sql, params);
|
||||
} catch (YankSQLException e) {
|
||||
throw new JdbcSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************
|
||||
* SQL generation Providers *
|
||||
****************************/
|
||||
|
|
Loading…
Reference in New Issue