You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I selected data from a table using Knex raw. In the AWS Lambda environment, I needed to correct JST to UTC. Actual SQL is much more complex. Below is an example code.
const result = await knex.raw<ContractInfo[]>("SELECT DISTINCT NO, DATECOLUMN FROM CONTRACT_TABLE");
result.forEach((row: ContractInfo) => {
if (row.DATECOLUMN ) {
const utc = row.DATECOLUMN ;
const jst = utc.setHours(utc.getHours() -9);
row.DATECOLUMN = jst;
}
});
For example, when there were 5 rows, the value of the Date type column was updated as shown below.
NO | DATECOLUMN
1 | 2024-03-19T00:00:00.000Z => updated to 2024-03-18T15:00:00.000Z. OK.
2 | 2024-03-19T00:00:00.000Z => updated to 2024-03-18T15:00:00.000Z. OK.
3 | NULL
4 | 2024-03-19T00:00:00.000Z => updated to 2024-03-18T06:00:00.000Z. NG. why ?
5 | 2024-03-19T00:00:00.000Z => updated to 2024-03-18T06:00:00.000Z. NG. why ?
The rows in the 4th and 5th rows refer to the same Date object, so it seems that the -9:00 update was applied twice.
I worked around this bug by copying the Date object and assigning it again. I hope that you will identify the cause of the bug and fix it. thank you.
Error message => No errors.
The text was updated successfully, but these errors were encountered:
Environment
Knex version: knex@2.5.1 (npm)
Database + version: Oracle 12 + Oracle Instant Client 21.11 + oracledb@6.2.0 (npm)
OS: AWS Lambda, Windows, node@v18-lts
@atiertant
Bug
For example, when there were 5 rows, the value of the Date type column was updated as shown below.
NO | DATECOLUMN
1 | 2024-03-19T00:00:00.000Z => updated to 2024-03-18T15:00:00.000Z. OK.
2 | 2024-03-19T00:00:00.000Z => updated to 2024-03-18T15:00:00.000Z. OK.
3 | NULL
4 | 2024-03-19T00:00:00.000Z => updated to 2024-03-18T06:00:00.000Z. NG. why ?
5 | 2024-03-19T00:00:00.000Z => updated to 2024-03-18T06:00:00.000Z. NG. why ?
The rows in the 4th and 5th rows refer to the same Date object, so it seems that the -9:00 update was applied twice.
I worked around this bug by copying the Date object and assigning it again. I hope that you will identify the cause of the bug and fix it. thank you.
The text was updated successfully, but these errors were encountered: