Skip to content

Commit

Permalink
fix: return interval as string
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed Jul 4, 2024
1 parent f39902d commit 7899b5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions test/server/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
]
`)
})

0 comments on commit 7899b5c

Please sign in to comment.