Skip to content

Commit 9686fdb

Browse files
authored
builtins: add range, multirange types (#165)
1 parent 27b22f4 commit 9686fdb

File tree

4 files changed

+58
-8
lines changed

4 files changed

+58
-8
lines changed

generator/docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,25 @@ services:
99
timeout: 5s
1010
retries: 5
1111

12+
postgres-14:
13+
image: postgres:14-alpine
14+
environment:
15+
POSTGRES_PASSWORD: postgres
16+
healthcheck:
17+
test: ["CMD-SHELL", "pg_isready"]
18+
interval: 5s
19+
timeout: 5s
20+
retries: 5
21+
1222
generator:
1323
image: node:20-alpine
1424
working_dir: /app
1525
command: node generator/generate.js
1626
depends_on:
1727
postgres-11:
1828
condition: service_healthy
29+
postgres-14:
30+
condition: service_healthy
1931
volumes:
2032
- ../:/app
2133
environment:

generator/generate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ const query = `
88
SELECT json_object_agg(UPPER(PT.typname), PT.oid::int4 ORDER BY pt.oid)
99
FROM pg_type PT
1010
WHERE typnamespace = (SELECT pgn.oid FROM pg_namespace pgn WHERE nspname = 'pg_catalog') -- Take only builting Postgres types with stable OID (extension types are not guaranted to be stable)
11-
AND typtype = 'b' -- Only basic types
11+
AND typtype IN ('b', 'r', 'm') -- Only basic (b), range (r), and multirange (m) types
1212
AND typelem = 0 -- Ignore aliases
1313
AND typisdefined -- Ignore undefined types
1414
`
1515

16-
const postgresVersions = ['11']
16+
const postgresVersions = ['11', '14']
1717

1818
async function queryPostgresVersion (version) {
1919
const host = `postgres-${version}`

lib/builtins.d.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ DO NOT EDIT THIS FILE BY HAND!
55
This file is generated automatically by the generator in generator/generate.js
66
To modify the types, edit the generator script and run: npm run generate
77
8-
Generated by querying PostgreSQL 11 to ensure comprehensive
8+
Generated by querying PostgreSQL 11, 14 to ensure comprehensive
99
type coverage for parsing.
1010
1111
Query used:
1212
SELECT json_object_agg(UPPER(PT.typname), PT.oid::int4 ORDER BY pt.oid)
1313
FROM pg_type PT
1414
WHERE typnamespace = (SELECT pgn.oid FROM pg_namespace pgn WHERE nspname = 'pg_catalog') -- Take only builting Postgres types with stable OID (extension types are not guaranted to be stable)
15-
AND typtype = 'b' -- Only basic types
15+
AND typtype IN ('b', 'r', 'm') -- Only basic (b), range (r), and multirange (m) types
1616
AND typelem = 0 -- Ignore aliases
1717
AND typisdefined -- Ignore undefined types
1818
*/
@@ -76,6 +76,25 @@ export enum builtins {
7676
REGCONFIG = 3734,
7777
REGDICTIONARY = 3769,
7878
JSONB = 3802,
79+
INT4RANGE = 3904,
80+
NUMRANGE = 3906,
81+
TSRANGE = 3908,
82+
TSTZRANGE = 3910,
83+
DATERANGE = 3912,
84+
INT8RANGE = 3926,
85+
JSONPATH = 4072,
7986
REGNAMESPACE = 4089,
80-
REGROLE = 4096
87+
REGROLE = 4096,
88+
REGCOLLATION = 4191,
89+
INT4MULTIRANGE = 4451,
90+
NUMMULTIRANGE = 4532,
91+
TSMULTIRANGE = 4533,
92+
TSTZMULTIRANGE = 4534,
93+
DATEMULTIRANGE = 4535,
94+
INT8MULTIRANGE = 4536,
95+
PG_BRIN_BLOOM_SUMMARY = 4600,
96+
PG_BRIN_MINMAX_MULTI_SUMMARY = 4601,
97+
PG_MCV_LIST = 5017,
98+
PG_SNAPSHOT = 5038,
99+
XID8 = 5069
81100
}

lib/builtins.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ DO NOT EDIT THIS FILE BY HAND!
55
This file is generated automatically by the generator in generator/generate.js
66
To modify the types, edit the generator script and run: npm run generate
77
8-
Generated by querying PostgreSQL 11 to ensure comprehensive
8+
Generated by querying PostgreSQL 11, 14 to ensure comprehensive
99
type coverage for parsing.
1010
1111
Query used:
1212
SELECT json_object_agg(UPPER(PT.typname), PT.oid::int4 ORDER BY pt.oid)
1313
FROM pg_type PT
1414
WHERE typnamespace = (SELECT pgn.oid FROM pg_namespace pgn WHERE nspname = 'pg_catalog') -- Take only builting Postgres types with stable OID (extension types are not guaranted to be stable)
15-
AND typtype = 'b' -- Only basic types
15+
AND typtype IN ('b', 'r', 'm') -- Only basic (b), range (r), and multirange (m) types
1616
AND typelem = 0 -- Ignore aliases
1717
AND typisdefined -- Ignore undefined types
1818
*/
@@ -76,6 +76,25 @@ module.exports = {
7676
REGCONFIG: 3734,
7777
REGDICTIONARY: 3769,
7878
JSONB: 3802,
79+
INT4RANGE: 3904,
80+
NUMRANGE: 3906,
81+
TSRANGE: 3908,
82+
TSTZRANGE: 3910,
83+
DATERANGE: 3912,
84+
INT8RANGE: 3926,
85+
JSONPATH: 4072,
7986
REGNAMESPACE: 4089,
80-
REGROLE: 4096
87+
REGROLE: 4096,
88+
REGCOLLATION: 4191,
89+
INT4MULTIRANGE: 4451,
90+
NUMMULTIRANGE: 4532,
91+
TSMULTIRANGE: 4533,
92+
TSTZMULTIRANGE: 4534,
93+
DATEMULTIRANGE: 4535,
94+
INT8MULTIRANGE: 4536,
95+
PG_BRIN_BLOOM_SUMMARY: 4600,
96+
PG_BRIN_MINMAX_MULTI_SUMMARY: 4601,
97+
PG_MCV_LIST: 5017,
98+
PG_SNAPSHOT: 5038,
99+
XID8: 5069
81100
}

0 commit comments

Comments
 (0)