Enum type not working in postgres
See original GitHub issueIssue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[x] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
TypeORM version:
[x] latest
[ ] @next
[ ] 0.2.0
(or put your version here)
Steps to reproduce or a small repository showing the problem:
type Action =
'add' |
'update' |
'delete';
@Entity()
export class DatasourceAction {
@PrimaryColumn()
id: string;
@Column({ name: 'name', type: 'text', unique: true })
name: string;
@Column({ name: 'action', type: 'enum', enum: ['add', 'update', 'delete'] })
action: Action;
}
The SQL quarries executed are as follows
CREATE TYPE "test"."datasource_action_action_enum" AS ENUM('add', 'update', 'delete')
ALTER TABLE "test"."datasource_action" ADD "action" "datasource_action_action_enum" NOT NUL
and it errors with type “datasource_action_action_enum” does not exist
I think the the ALTER TABLE query should have been as follows. ALTER TABLE “test”.“datasource_action” ADD “action” “test”.“datasource_action_action_enum” NOT NUL
Issue Analytics
- State:
- Created 5 years ago
- Reactions:21
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Documentation: 15: 8.7. Enumerated Types - PostgreSQL
Enumerated (enum) types are data types that comprise a static, ordered set of values. They are equivalent to the enum types supported in...
Read more >Postgres ENUM data type or CHECK CONSTRAINT?
Disadvantages are, the ENUM type is stored in system catalogs, so a query as above is required to view its definition. These values...
Read more >Dealing with Enum Type in PostgreSQL - DEV Community
The workaround is the same as above: rename old type, create new and correct type, and delete old type.
Read more >PostgreSQL Data Types: ENUM
When using PostgreSQL, each ENUM type is registered in the system catalogs and can be used anywhere PostgreSQL expects a type name. Internally, ......
Read more >How enum works in PostgreSQL? (Examples) - eduCBA
PostgreSQL enum is the data type that was used in PostgreSQL to stored same type of values in column field, we can store...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop 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
Top GitHub Comments
I hit the same problem
Gender enum class
@pleerock I added all the previous enum tests with external schema as part of the PR, I also used this by manually patching typeorm in prod, let me know how I can assist to move this forward.