diff --git a/cjs/src/postgres.js b/cjs/src/postgres.js index 1d38f25..1f4d92c 100644 --- a/cjs/src/postgres.js +++ b/cjs/src/postgres.js @@ -18,7 +18,7 @@ const typeMapping = { function getTableDefinitions (sql, schema) { return sql` SELECT c.table_name AS name, - obj_description(c.table_name::regclass) AS comment, + obj_description(('"' || c.table_name || '"')::regclass) AS comment, t.table_type = 'VIEW' AS "isView", jsonb_agg( DISTINCT jsonb_build_object( @@ -31,7 +31,7 @@ function getTableDefinitions (sql, schema) { 'comment', ( SELECT coalesce(pg_catalog.col_description(pc.oid, c.ordinal_position::int), '') FROM pg_catalog.pg_class pc - WHERE pc.oid = c.table_name::regclass::oid + WHERE pc.oid = (('"' || c.table_name || '"')::regclass)::oid AND pc.relname = c.table_name ), 'indices', ( diff --git a/cjs/test/cli.js b/cjs/test/cli.js index 103bf9e..2e81560 100644 --- a/cjs/test/cli.js +++ b/cjs/test/cli.js @@ -123,7 +123,7 @@ t.test('reports success to stdout', t => { }) child.on('close', () => { - t.equal(result.data, '✔ Generated types from 9 tables and 4 enums\n') + t.equal(result.data, '✔ Generated types from 10 tables and 4 enums\n') }) }) @@ -167,7 +167,7 @@ t.test('generates types with header', t => { }) }) -t.only('generates types with pascal case enums', t => { +t.test('generates types with pascal case enums', t => { t.plan(1) const child = childProcess.spawn(process.execPath, [path.join(__dirname, '..', 'src', 'index.js'), connection, ssl ? '--ssl' : '', '--pascal-enums'], { diff --git a/cjs/test/helpers/setup-postgres.js b/cjs/test/helpers/setup-postgres.js index f57d393..38629b8 100644 --- a/cjs/test/helpers/setup-postgres.js +++ b/cjs/test/helpers/setup-postgres.js @@ -90,6 +90,14 @@ module.exports.setupTestPostgres = setupTestPostgres; async function setupTestPo COMMENT ON COLUMN users.name IS 'Very long long long long long long long long long long long long long long long long long long long long long comment'; ` + await sql` + CREATE TABLE IF NOT EXISTS "PascalTableName" + ( + id serial4 NOT NULL, + "Name" text NOT NULL + ); + ` + await sql` CREATE TABLE IF NOT EXISTS "kebab-test" ( id int4 NOT NULL diff --git a/src/postgres.js b/src/postgres.js index 4c48f82..00dc28d 100644 --- a/src/postgres.js +++ b/src/postgres.js @@ -18,7 +18,7 @@ const typeMapping = { function getTableDefinitions (sql, schema) { return sql` SELECT c.table_name AS name, - obj_description(c.table_name::regclass) AS comment, + obj_description(('"' || c.table_name || '"')::regclass) AS comment, t.table_type = 'VIEW' AS "isView", jsonb_agg( DISTINCT jsonb_build_object( @@ -31,7 +31,7 @@ function getTableDefinitions (sql, schema) { 'comment', ( SELECT coalesce(pg_catalog.col_description(pc.oid, c.ordinal_position::int), '') FROM pg_catalog.pg_class pc - WHERE pc.oid = c.table_name::regclass::oid + WHERE pc.oid = (('"' || c.table_name || '"')::regclass)::oid AND pc.relname = c.table_name ), 'indices', ( diff --git a/tap-snapshots/cjs/test/cli.js.test.cjs b/tap-snapshots/cjs/test/cli.js.test.cjs index 2f31882..5b8ecd0 100644 --- a/tap-snapshots/cjs/test/cli.js.test.cjs +++ b/tap-snapshots/cjs/test/cli.js.test.cjs @@ -6,7 +6,7 @@ */ 'use strict' exports['cjs/test/cli.js > TAP > generates table names > must match snapshot 1'] = ` -export type Tables = 'address' | 'histories' | 'kebab-test' | 'snake_test' | 'types' | 'users' +export type Tables = 'address' | 'histories' | 'kebab-test' | 'PascalTableName' | 'snake_test' | 'types' | 'users' export enum DeliciousKebab { 'big-mix' = 'big-mix', @@ -54,6 +54,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -232,6 +237,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -410,6 +420,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -587,6 +602,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -765,6 +785,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SomeViewEntity { test: number | null test_text: string | null @@ -831,6 +856,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1021,6 +1051,16 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + +export interface PascalTableNameInsertEntity { + id?: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1322,6 +1362,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1500,6 +1545,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1678,6 +1728,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1856,6 +1911,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null; }; +export interface PascalTableNameEntity { + id: number; + Name: string; +}; + export interface SnakeTestEntity { id: number; }; @@ -2034,6 +2094,11 @@ export type MaterializedOtherItemEntity = { test_text: string | null } +export type PascalTableNameEntity = { + id: number + Name: string +} + export type SnakeTestEntity = { id: number } diff --git a/tap-snapshots/cjs/test/pg-typegen.js.test.cjs b/tap-snapshots/cjs/test/pg-typegen.js.test.cjs index 9ae0dab..f9d2821 100644 --- a/tap-snapshots/cjs/test/pg-typegen.js.test.cjs +++ b/tap-snapshots/cjs/test/pg-typegen.js.test.cjs @@ -148,6 +148,31 @@ Object { "isView": true, "name": "materialized_other_items", }, + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { @@ -1342,6 +1367,7 @@ Object { "address": "AddressInsertEntity", "histories": "HistoryInsertEntity", "kebab-test": "KebabTestInsertEntity", + "PascalTableName": "PascalTableNameInsertEntity", "snake_test": "SnakeTestInsertEntity", "types": "TypeInsertEntity", "users": "UserInsertEntity", @@ -1352,6 +1378,7 @@ Object { "kebab-test": "KebabTestEntity", "materialized_items": "MaterializedItemEntity", "materialized_other_items": "MaterializedOtherItemEntity", + "PascalTableName": "PascalTableNameEntity", "snake_test": "SnakeTestEntity", "some_view": "SomeViewEntity", "types": "TypeEntity", @@ -1416,6 +1443,16 @@ Object { test_text: string | null } + export interface PascalTableNameEntity { + id: number + Name: string + } + + export interface PascalTableNameInsertEntity { + id?: number + Name: string + } + export interface SnakeTestEntity { id: number } @@ -1718,6 +1755,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1895,6 +1937,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -2026,7 +2073,7 @@ export interface UserEntity { ` exports['cjs/test/pg-typegen.js > TAP > generates types to file > must match snapshot 2'] = ` -✔ Generated types from 9 tables and 4 enums +✔ Generated types from 10 tables and 4 enums ` exports['cjs/test/pg-typegen.js > TAP > generates types with comments > must match snapshot 1'] = ` @@ -2076,6 +2123,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { /** * PRIMARY KEY @@ -2278,6 +2330,16 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + +export interface PascalTableNameInsertEntity { + id?: number + Name: string +} + export interface SnakeTestEntity { /** * PRIMARY KEY @@ -2616,6 +2678,16 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + +export interface PascalTableNameInsertEntity { + id?: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -2925,6 +2997,13 @@ export type MaterializedOtherItemEntity = { 'materialized_other_items.test_text'?: string } +export type PascalTableNameEntity = { + id: number + 'PascalTableName.id': number + Name: string + 'PascalTableName.Name': string +} + export type SnakeTestEntity = { id: number 'snake_test.id': number @@ -3227,6 +3306,13 @@ export type MaterializedOtherItemEntity = { 'materialized_other_items.test_text': string | null } +export type PascalTableNameEntity = { + id: number + 'PascalTableName.id': number + Name: string + 'PascalTableName.Name': string +} + export type SnakeTestEntity = { id: number 'snake_test.id': number diff --git a/tap-snapshots/cjs/test/postgres.js.test.cjs b/tap-snapshots/cjs/test/postgres.js.test.cjs index c3a7ada..d4a7b39 100644 --- a/tap-snapshots/cjs/test/postgres.js.test.cjs +++ b/tap-snapshots/cjs/test/postgres.js.test.cjs @@ -40,6 +40,31 @@ Object { }, ], "tables": Array [ + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { @@ -1343,6 +1368,31 @@ Object { }, ], "tables": Array [ + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { @@ -2660,6 +2710,31 @@ Object { }, ], "tables": Array [ + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { @@ -3981,6 +4056,31 @@ Object { }, ], "tables": Array [ + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { @@ -5294,6 +5394,31 @@ Object { }, ], "tables": Array [ + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { diff --git a/tap-snapshots/test/cli.js.test.cjs b/tap-snapshots/test/cli.js.test.cjs index 2bdd58f..2eebaed 100644 --- a/tap-snapshots/test/cli.js.test.cjs +++ b/tap-snapshots/test/cli.js.test.cjs @@ -6,7 +6,7 @@ */ 'use strict' exports['test/cli.js > TAP > generates table names > must match snapshot 1'] = ` -export type Tables = 'address' | 'histories' | 'kebab-test' | 'snake_test' | 'types' | 'users' +export type Tables = 'address' | 'histories' | 'kebab-test' | 'PascalTableName' | 'snake_test' | 'types' | 'users' export enum DeliciousKebab { 'big-mix' = 'big-mix', @@ -54,6 +54,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -232,6 +237,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -410,6 +420,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -587,6 +602,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -765,6 +785,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SomeViewEntity { test: number | null test_text: string | null @@ -831,6 +856,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1021,6 +1051,16 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + +export interface PascalTableNameInsertEntity { + id?: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1322,6 +1362,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1500,6 +1545,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1678,6 +1728,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1856,6 +1911,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null; }; +export interface PascalTableNameEntity { + id: number; + Name: string; +}; + export interface SnakeTestEntity { id: number; }; @@ -2034,6 +2094,11 @@ export type MaterializedOtherItemEntity = { test_text: string | null } +export type PascalTableNameEntity = { + id: number + Name: string +} + export type SnakeTestEntity = { id: number } diff --git a/tap-snapshots/test/pg-typegen.js.test.cjs b/tap-snapshots/test/pg-typegen.js.test.cjs index 9aaec6a..21adf5a 100644 --- a/tap-snapshots/test/pg-typegen.js.test.cjs +++ b/tap-snapshots/test/pg-typegen.js.test.cjs @@ -148,6 +148,31 @@ Object { "isView": true, "name": "materialized_other_items", }, + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { @@ -1342,6 +1367,7 @@ Object { "address": "AddressInsertEntity", "histories": "HistoryInsertEntity", "kebab-test": "KebabTestInsertEntity", + "PascalTableName": "PascalTableNameInsertEntity", "snake_test": "SnakeTestInsertEntity", "types": "TypeInsertEntity", "users": "UserInsertEntity", @@ -1352,6 +1378,7 @@ Object { "kebab-test": "KebabTestEntity", "materialized_items": "MaterializedItemEntity", "materialized_other_items": "MaterializedOtherItemEntity", + "PascalTableName": "PascalTableNameEntity", "snake_test": "SnakeTestEntity", "some_view": "SomeViewEntity", "types": "TypeEntity", @@ -1416,6 +1443,16 @@ Object { test_text: string | null } + export interface PascalTableNameEntity { + id: number + Name: string + } + + export interface PascalTableNameInsertEntity { + id?: number + Name: string + } + export interface SnakeTestEntity { id: number } @@ -1718,6 +1755,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -1895,6 +1937,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -2026,7 +2073,7 @@ export interface UserEntity { ` exports['test/pg-typegen.js > TAP > generates types to file > must match snapshot 2'] = ` -✔ Generated types from 9 tables and 4 enums +✔ Generated types from 10 tables and 4 enums ` exports['test/pg-typegen.js > TAP > generates types with comments > must match snapshot 1'] = ` @@ -2076,6 +2123,11 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + export interface SnakeTestEntity { /** * PRIMARY KEY @@ -2278,6 +2330,16 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + +export interface PascalTableNameInsertEntity { + id?: number + Name: string +} + export interface SnakeTestEntity { /** * PRIMARY KEY @@ -2616,6 +2678,16 @@ export interface MaterializedOtherItemEntity { test_text: string | null } +export interface PascalTableNameEntity { + id: number + Name: string +} + +export interface PascalTableNameInsertEntity { + id?: number + Name: string +} + export interface SnakeTestEntity { id: number } @@ -2925,6 +2997,13 @@ export type MaterializedOtherItemEntity = { 'materialized_other_items.test_text'?: string } +export type PascalTableNameEntity = { + id: number + 'PascalTableName.id': number + Name: string + 'PascalTableName.Name': string +} + export type SnakeTestEntity = { id: number 'snake_test.id': number @@ -3227,6 +3306,13 @@ export type MaterializedOtherItemEntity = { 'materialized_other_items.test_text': string | null } +export type PascalTableNameEntity = { + id: number + 'PascalTableName.id': number + Name: string + 'PascalTableName.Name': string +} + export type SnakeTestEntity = { id: number 'snake_test.id': number diff --git a/tap-snapshots/test/postgres.js.test.cjs b/tap-snapshots/test/postgres.js.test.cjs index 7450728..f7ae3a9 100644 --- a/tap-snapshots/test/postgres.js.test.cjs +++ b/tap-snapshots/test/postgres.js.test.cjs @@ -40,6 +40,31 @@ Object { }, ], "tables": Array [ + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { @@ -1343,6 +1368,31 @@ Object { }, ], "tables": Array [ + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { @@ -2660,6 +2710,31 @@ Object { }, ], "tables": Array [ + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { @@ -3981,6 +4056,31 @@ Object { }, ], "tables": Array [ + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { @@ -5294,6 +5394,31 @@ Object { }, ], "tables": Array [ + Object { + "columns": Array [ + Object { + "comment": "", + "defaultValue": "nextval('\\"PascalTableName_id_seq\\"'::regclass)", + "hasDefault": true, + "indices": Array [], + "isNullable": false, + "name": "id", + "type": "int4", + }, + Object { + "comment": "", + "defaultValue": null, + "hasDefault": false, + "indices": Array [], + "isNullable": false, + "name": "Name", + "type": "text", + }, + ], + "comment": null, + "isView": false, + "name": "PascalTableName", + }, Object { "columns": Array [ Object { diff --git a/test/cli.js b/test/cli.js index feeb140..2c1918e 100644 --- a/test/cli.js +++ b/test/cli.js @@ -126,7 +126,7 @@ t.test('reports success to stdout', t => { }) child.on('close', () => { - t.equal(result.data, '✔ Generated types from 9 tables and 4 enums\n') + t.equal(result.data, '✔ Generated types from 10 tables and 4 enums\n') }) }) @@ -170,7 +170,7 @@ t.test('generates types with header', t => { }) }) -t.only('generates types with pascal case enums', t => { +t.test('generates types with pascal case enums', t => { t.plan(1) const child = childProcess.spawn(process.execPath, [path.join(__dirname, '..', 'src', 'index.js'), connection, ssl ? '--ssl' : '', '--pascal-enums'], { diff --git a/test/helpers/setup-postgres.js b/test/helpers/setup-postgres.js index a094f2e..ac44ef4 100644 --- a/test/helpers/setup-postgres.js +++ b/test/helpers/setup-postgres.js @@ -91,6 +91,14 @@ export async function setupTestPostgres () { COMMENT ON COLUMN users.name IS 'Very long long long long long long long long long long long long long long long long long long long long long comment'; ` + await sql` + CREATE TABLE IF NOT EXISTS "PascalTableName" + ( + id serial4 NOT NULL, + "Name" text NOT NULL + ); + ` + await sql` CREATE TABLE IF NOT EXISTS "kebab-test" ( id int4 NOT NULL