From 7899b5cf78ffe26f5388aeb9dd4558e2f6ade435 Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo Date: Thu, 4 Jul 2024 18:21:32 +0800 Subject: [PATCH] fix: return `interval` as string --- src/lib/db.ts | 1 + test/server/query.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/lib/db.ts b/src/lib/db.ts index b17a013e..464c7410 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -12,6 +12,7 @@ pg.types.setTypeParser(pg.types.builtins.INT8, (x) => { } }) pg.types.setTypeParser(pg.types.builtins.DATE, (x) => x) +pg.types.setTypeParser(pg.types.builtins.INTERVAL, (x) => x) pg.types.setTypeParser(pg.types.builtins.TIMESTAMP, (x) => x) pg.types.setTypeParser(pg.types.builtins.TIMESTAMPTZ, (x) => x) pg.types.setTypeParser(1115, parseArray) // _timestamp diff --git a/test/server/query.ts b/test/server/query.ts index 04ba102a..26b01f80 100644 --- a/test/server/query.ts +++ b/test/server/query.ts @@ -539,3 +539,21 @@ test('very big number', async () => { ] `) }) + +// issue: https://github.com/supabase/supabase/issues/27626 +test('return interval as string', async () => { + const res = await app.inject({ + method: 'POST', + path: '/query', + payload: { + query: `SELECT '1 day 1 hour 45 minutes'::interval`, + }, + }) + expect(res.json()).toMatchInlineSnapshot(` + [ + { + "interval": "1 day 01:45:00", + }, + ] + `) +})