From 69b0ec94d09ad8f60364987d9018fb7fb18a30c6 Mon Sep 17 00:00:00 2001 From: Aldis Ameriks Date: Fri, 4 Sep 2020 20:07:08 +0300 Subject: [PATCH] fix: bigint mapping for arrays --- lib/postgres.js | 7 ++++-- tap-snapshots/test-cli.js-TAP.test.js | 4 ++-- tap-snapshots/test-postgres.js-TAP.test.js | 28 ++++++++++++++++++---- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/lib/postgres.js b/lib/postgres.js index 5dfb14b..643f6a6 100644 --- a/lib/postgres.js +++ b/lib/postgres.js @@ -9,11 +9,12 @@ const typeMapping = { bigint: [], object: ['json', 'jsonb'], Date: ['timestamp', 'timestamptz'], - 'Array': ['_bpchar', '_char', '_varchar', '_text', '_uuid', '_bytea', '_inet', '_int8', '_time', '_timetz', '_interval', '_name'], + 'Array': ['_bpchar', '_char', '_varchar', '_text', '_uuid', '_bytea', '_inet', '_time', '_timetz', '_interval', '_name'], 'Array': ['_int2', '_int4', '_float4', '_float8', '_numeric', '_money', '_oid'], 'Array': ['_bool'], 'Array': ['_json', '_jsonb'], - 'Array': ['_timestamp', '_timestamptz'] + 'Array': ['_timestamp', '_timestamptz'], + 'Array': [] } function getTableDefinitions (sql, schema) { @@ -52,8 +53,10 @@ async function getSchemaDefinition (opts) { if (bigint) { typeMapping.bigint.push('int8') + typeMapping['Array'].push('_int8') } else { typeMapping.string.push('int8') + typeMapping['Array'].push('_int8') } if (dateAsString) { diff --git a/tap-snapshots/test-cli.js-TAP.test.js b/tap-snapshots/test-cli.js-TAP.test.js index 51d01ad..eea9988 100644 --- a/tap-snapshots/test-cli.js-TAP.test.js +++ b/tap-snapshots/test-cli.js-TAP.test.js @@ -322,7 +322,7 @@ export interface TypeEntity { avatar_rozella: Array; camelCase: boolean | null; category_amari: number; - category_april: Array; + category_april: Array; category_buddy: Array | null; category_clementine: number | null; category_marcelle: Date | null; @@ -352,7 +352,7 @@ export interface TypeEntity { group_jedediah: Array; group_shanny: Date; group_toby: string; - group_ulices: Array | null; + group_ulices: Array | null; id_gay: string; id_hailee: object; id_helen: Array | null; diff --git a/tap-snapshots/test-postgres.js-TAP.test.js b/tap-snapshots/test-postgres.js-TAP.test.js index de65f71..69c7ac6 100644 --- a/tap-snapshots/test-postgres.js-TAP.test.js +++ b/tap-snapshots/test-postgres.js-TAP.test.js @@ -603,6 +603,7 @@ Object { }, ], "typeMapping": Object { + "Array": Array [], "Array": Array [ "_bool", ], @@ -632,11 +633,11 @@ Object { "_uuid", "_bytea", "_inet", - "_int8", "_time", "_timetz", "_interval", "_name", + "_int8", ], "bigint": Array [], "boolean": Array [ @@ -1276,6 +1277,9 @@ Object { }, ], "typeMapping": Object { + "Array": Array [ + "_int8", + ], "Array": Array [ "_bool", ], @@ -1308,11 +1312,13 @@ Object { "_uuid", "_bytea", "_inet", - "_int8", "_time", "_timetz", "_interval", "_name", + "_int8", + "_int8", + "_int8", ], "bigint": Array [ "int8", @@ -1959,6 +1965,9 @@ Object { }, ], "typeMapping": Object { + "Array": Array [ + "_int8", + ], "Array": Array [ "_bool", ], @@ -1991,11 +2000,14 @@ Object { "_uuid", "_bytea", "_inet", - "_int8", "_time", "_timetz", "_interval", "_name", + "_int8", + "_int8", + "_int8", + "_int8", "_date", ], "bigint": Array [ @@ -2645,6 +2657,9 @@ Object { }, ], "typeMapping": Object { + "Array": Array [ + "_int8", + ], "Array": Array [ "_bool", ], @@ -2676,11 +2691,12 @@ Object { "_uuid", "_bytea", "_inet", - "_int8", "_time", "_timetz", "_interval", "_name", + "_int8", + "_int8", ], "bigint": Array [ "int8", @@ -3325,6 +3341,7 @@ Object { }, ], "typeMapping": Object { + "Array": Array [], "Array": Array [ "_bool", ], @@ -3355,11 +3372,12 @@ Object { "_uuid", "_bytea", "_inet", - "_int8", "_time", "_timetz", "_interval", "_name", + "_int8", + "_int8", ], "bigint": Array [], "boolean": Array [