mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
fix(core): update timestamp field with millisecond precision (#677)
This commit is contained in:
parent
e7fe1200ce
commit
7278ba4095
3 changed files with 5 additions and 5 deletions
packages/core/src
|
@ -56,9 +56,9 @@ describe('convertToPrimitiveOrSql()', () => {
|
|||
it('converts value to sql when key ends with special set and value is number', () => {
|
||||
for (const value of timestampKeyEndings) {
|
||||
expect(convertToPrimitiveOrSql(`${normalKey}${value}`, 12_341_234)).toEqual({
|
||||
sql: 'to_timestamp($1)',
|
||||
sql: 'to_timestamp($1::double precision / 1000)',
|
||||
type: SqlToken,
|
||||
values: [12_341.234],
|
||||
values: [12_341_234],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -42,7 +42,7 @@ export const convertToPrimitiveOrSql = (
|
|||
}
|
||||
|
||||
if (['_at', 'At'].some((value) => key.endsWith(value)) && typeof value === 'number') {
|
||||
return sql`to_timestamp(${value / 1000})`;
|
||||
return sql`to_timestamp(${value}::double precision / 1000)`;
|
||||
}
|
||||
|
||||
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
||||
|
|
|
@ -46,7 +46,7 @@ describe('oidc-model-instance query', () => {
|
|||
it('upsertInstance', async () => {
|
||||
const expectSql = sql`
|
||||
insert into ${table} ("model_name", "id", "payload", "expires_at")
|
||||
values ($1, $2, $3, to_timestamp($4))
|
||||
values ($1, $2, $3, to_timestamp($4::double precision / 1000))
|
||||
on conflict ("model_name", "id") do update
|
||||
set "payload"=excluded."payload", "expires_at"=excluded."expires_at"
|
||||
`;
|
||||
|
@ -57,7 +57,7 @@ describe('oidc-model-instance query', () => {
|
|||
instance.modelName,
|
||||
instance.id,
|
||||
JSON.stringify(instance.payload),
|
||||
instance.expiresAt / 1000,
|
||||
instance.expiresAt,
|
||||
]);
|
||||
|
||||
return createMockQueryResult([databaseValue]);
|
||||
|
|
Loading…
Reference in a new issue