Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions src/schemaPostgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export class PostgresDatabase implements Database {
if (customTypes.indexOf(column.udtName) !== -1) {
column.tsType = options.transformTypeName(column.udtName)
return column
} else if(customTypes.map(type => `_${type}`).indexOf(column.udtName) !== -1) {
column.tsType = `Array<${options.transformTypeName(column.udtName)}>`
return column
} else {
console.log(`Type [${column.udtName} has been mapped to [any] because no specific type has been found.`)
column.tsType = 'any'
Expand Down
2 changes: 2 additions & 0 deletions test/expected/postgres/osm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export namespace usersFields {
export type json_array_col = Array<Object> | null;
export type jsonb_array_col = Array<Object> | null;
export type timestamptz_array_col = Array<Date> | null;
export type formats = Array<format_enum> | null;

}

Expand Down Expand Up @@ -130,4 +131,5 @@ export interface users {
json_array_col: usersFields.json_array_col;
jsonb_array_col: usersFields.jsonb_array_col;
timestamptz_array_col: usersFields.timestamptz_array_col;
formats: usersFields.formats;
}
3 changes: 2 additions & 1 deletion test/fixture/postgres/osm.sql
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ CREATE TABLE users (
name_type_col name,
json_array_col json[],
jsonb_array_col jsonb[],
timestamptz_array_col timestamptz[]
timestamptz_array_col timestamptz[],
formats format_enum[]
);