TypeError: Cannot read property 'map' of undefined in PostgresQueryRunner.createEnumTypeSql
See original GitHub issueIssue type: bug report
Database system/driver: postgres
TypeORM version: 0.2.6
as reported by
$ typeorm version
Local installed version: 0.2.6
Global installed TypeORM version: 0.2.6
Steps to reproduce or a small repository showing the problem:
The cause seems to be this entity:
enum State {
Running = 0,
Completed = 1,
}
@Entity('presence_list_item')
export class Presence {
@PrimaryGeneratedColumn('uuid')
public id!: string
@Column('enum', {nullable: false})
public state!: State
}
And TypeORM dies when I attempt to sync the schema:
$ typeorm schema:sync
query: START TRANSACTION
query: SELECT * FROM current_schema()
query: SELECT * FROM "information_schema"."tables" WHERE ...
query: SELECT "ns"."nspname" AS "table_schema", "t"."relname" AS "table_name", "cnst"."conname" AS "constraint_name", "cnst"."consrc" AS "expression", CASE "cnst"."contype" WHEN 'p' THEN 'PRIMARY' WHEN 'u' THEN 'UNIQUE' WHEN 'c' THEN 'CHECK' END AS "constraint_type", "a"."attname" AS "column_name" FROM "pg_constraint" "cnst" INNER JOIN "pg_class" "t" ON "t"."oid" = "cnst"."conrelid" INNER JOIN "pg_namespace" "ns" ON "ns"."oid" = "cnst"."connamespace" INNER JOIN "pg_attribute" "a" ON "a"."attrelid" = "cnst"."conrelid" AND "a"."attnum" = ANY ("cnst"."conkey") WHERE ...
query: SELECT "ns"."nspname" AS "table_schema", "t"."relname" AS "table_name", "i"."relname" AS "constraint_name", "a"."attname" AS "column_name", CASE "ix"."indisunique" WHEN 't' THEN 'TRUE' ELSE'FALSE' END AS "is_unique", pg_get_expr("ix"."indpred", "ix"."indrelid") AS "condition" FROM "pg_class" "t" INNER JOIN "pg_index" "ix" ON "ix"."indrelid" = "t"."oid" INNER JOIN "pg_attribute" "a" ON "a"."attrelid" = "t"."oid" AND "a"."attnum" = ANY ("ix"."indkey") INNER JOIN "pg_namespace" "ns" ON "ns"."oid" = "t"."relnamespace" INNER JOIN "pg_class" "i" ON "i"."oid" = "ix"."indexrelid" LEFT JOIN "pg_constraint" "cnst" ON "cnst"."conname" = "i"."relname" WHERE ...
query: SELECT "con"."conname" AS "constraint_name", "con"."nspname" AS "table_schema", "con"."relname" AS "table_name", "att2"."attname" AS "column_name", "ns"."nspname" AS "referenced_table_schema", "cl"."relname" AS "referenced_table_name", "att"."attname" AS "referenced_column_name", "con"."confdeltype" AS "on_delete", "con"."confupdtype" AS "on_update" FROM ( SELECT UNNEST ("con1"."conkey") AS "parent", UNNEST ("con1"."confkey") AS "child", "con1"."confrelid", "con1"."conrelid", "con1"."conname", "con1"."contype", "ns"."nspname", "cl"."relname", CASE "con1"."confdeltype" WHEN 'a' THEN 'NO ACTION' WHEN 'r' THEN 'RESTRICT' WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' END as "confdeltype", CASE "con1"."confupdtype" WHEN 'a' THEN 'NO ACTION' WHEN 'r' THEN 'RESTRICT' WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' END as "confupdtype" FROM "pg_class" "cl" INNER JOIN "pg_namespace" "ns" ON "cl"."relnamespace" = "ns"."oid" INNER JOIN "pg_constraint" "con1" ON "con1"."conrelid" = "cl"."oid" WHERE ...
...
creating a new table: presence_list_item
query: SELECT "n"."nspname", "t"."typname" FROM "pg_type" "t" INNER JOIN "pg_namespace" "n" ON "n"."oid" = "t"."typnamespace" WHERE "n"."nspname" = current_schema() AND "t"."typname" = 'presence_list_item_state_enum'
query: ROLLBACK
Error during schema synchronization:
TypeError: Cannot read property 'map' of undefined
at PostgresQueryRunner.createEnumTypeSql (~/lib/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:2046:38)
at PostgresQueryRunner.<anonymous> (~/lib/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:447:69)
at step (~/lib/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:42:23)
at Object.next (~/lib/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:23:53)
at fulfilled (~/lib/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:14:58)
at process._tickCallback (internal/process/next_tick.js:68:7)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:20 (3 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'map' of undefined in react.js
The initial value of musics state is undefined. You should give initial value like this. const [musics, setMusics] = useState([]).
Read more >Jammming project - Cannot read property 'map' of undefined
My app is erroring in the TrackList.js file on line 8, with “TypeError: Cannot read property 'map' of undefined”.
Read more >type-graphql/Lobby - Gitter
am i right that i can't use class-validator for nested InputTypes? ... TypeError: Cannot read property 'map' of undefined app | at PostgresQueryRunner....
Read more >Cannot read property 'map' of undefined | by May Guo - Medium
I wanted to pull in all the Pokemon and display them in cards. I used useState to set my pokemons variable to an...
Read more >地图不是函数JavaScript, this.state.data.map 不是函数reactjs, Items ...
不断收到TypeError: Cannot read property 'map' of undefined。 ... createEnumTypeSql #2233 Open lorenzleutgeb 打开了这个问题2018 年5 月30 日· 12 条评论。
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
you have to provide enum this way:
I don’t think that what you provide here is a fix. You just show a correct declaration for a property that should map to an enumeration (the same way @pleerock did in the second comment). However, what was asked for (in my answer to that comment) is an improved error message in case the declaration is erroneous.
To make it even more clear, IMO a fix would be a patch to the TypeORM codebase that analyzes enum declarations more thoroughly and presents a more insightful error message as to why the declaration is not accepted.