Skip to content

fix: #143, #174, #175 #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: return date, timestamp, timestamptz as string
  • Loading branch information
soedirgo committed Jan 26, 2022
commit a1fe9003afbece62e25f0948a31b8f79f3b6fde5
30 changes: 23 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"test": "run-s db:clean db:run test:run db:clean",
"db:clean": "cd test/db && docker-compose down",
"db:run": "cd test/db && docker-compose up --detach && sleep 5",
"test:run": "jest --runInBand"
"test:run": "jest --runInBand",
"test:update": "run-s db:clean db:run && jest --runInBand --updateSnapshot && run-s db:clean"
},
"engines": {
"node": ">=14 <15",
Expand All @@ -38,6 +39,7 @@
"pg-format": "^1.0.4",
"pgsql-parser": "^13.1.11",
"pino": "^7.6.3",
"postgres-array": "^3.0.1",
"prettier": "^2.4.1",
"prettier-plugin-sql": "^0.4.0",
"sql-formatter": "^4.0.2"
Expand Down
9 changes: 8 additions & 1 deletion src/lib/db.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { types, Pool, PoolConfig } from 'pg'
import { parse as parseArray } from 'postgres-array'
import { PostgresMetaResult } from './types'

types.setTypeParser(20, parseInt)
types.setTypeParser(types.builtins.INT8, parseInt)
types.setTypeParser(types.builtins.DATE, (x) => x)
types.setTypeParser(types.builtins.TIMESTAMP, (x) => x)
types.setTypeParser(types.builtins.TIMESTAMPTZ, (x) => x)
types.setTypeParser(1115, parseArray) // _timestamp
types.setTypeParser(1182, parseArray) // _date
types.setTypeParser(1185, parseArray) // _timestamptz

export const init: (config: PoolConfig) => {
query: (sql: string) => Promise<PostgresMetaResult<any>>
Expand Down
8 changes: 4 additions & 4 deletions test/lib/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ test('retrieve, create, update, delete', async () => {
"is_superuser": true,
"name": "r",
"password": "********",
"valid_until": 2020-01-01T00:00:00.000Z,
"valid_until": "2020-01-01 00:00:00+00",
},
"error": null,
}
Expand All @@ -467,7 +467,7 @@ test('retrieve, create, update, delete', async () => {
"is_superuser": true,
"name": "r",
"password": "********",
"valid_until": 2020-01-01T00:00:00.000Z,
"valid_until": "2020-01-01 00:00:00+00",
},
"error": null,
}
Expand Down Expand Up @@ -507,7 +507,7 @@ test('retrieve, create, update, delete', async () => {
"is_superuser": true,
"name": "rr",
"password": "********",
"valid_until": 2020-01-01T00:00:00.000Z,
"valid_until": "2020-01-01 00:00:00+00",
},
"error": null,
}
Expand All @@ -532,7 +532,7 @@ test('retrieve, create, update, delete', async () => {
"is_superuser": true,
"name": "rr",
"password": "********",
"valid_until": 2020-01-01T00:00:00.000Z,
"valid_until": "2020-01-01 00:00:00+00",
},
"error": null,
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy