-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue Description
It seems that enum types does not work with cochroachdb as driver. If you use postgres it works.
Expected Behavior
It should support / create the custom enum type just like it does in postgres. Enums are supported by cockroachdb.
If you set the driver to postgres against an cockroacbdb instance, it will work just fine.
Actual Behavior
This error is outputted:
[Nest] 64905 - 06/02/2022, 2:14:26 PM ERROR [ExceptionHandler] Data type "enum" in "User.gender" is not supported by "cockroachdb" database.
DataTypeNotSupportedError: Data type "enum" in "User.gender" is not supported by "cockroachdb" database.
at DataTypeNotSupportedError.TypeORMError [as constructor] (/Users/mf/Projects/project/backend/src/error/TypeORMError.ts:7:9)
at new DataTypeNotSupportedError (/Users/mf/Projects/project/backend/src/error/DataTypeNotSupportedError.ts:8:9)
at /Users/mf/Projects/project/backend/src/metadata-builder/EntityMetadataValidator.ts:89:27
at Array.forEach (<anonymous>)
at EntityMetadataValidator.validate (/Users/mf/Projects/project/backend/src/metadata-builder/EntityMetadataValidator.ts:86:36)
at /Users/mf/Projects/project/backend/src/metadata-builder/EntityMetadataValidator.ts:46:56
at Array.forEach (<anonymous>)
at EntityMetadataValidator.validateMany (/Users/mf/Projects/project/backend/src/metadata-builder/EntityMetadataValidator.ts:46:25)
at Connection.<anonymous> (/Users/mf/Projects/project/backend/src/connection/Connection.ts:533:33)
at step (/Users/mf/Projects/project/backend/node_modules/tslib/tslib.js:143:27)
If you first set the driver to be postgres, and then go into your cockroachdb, and call SHOW ENUMS;, you'll actually see the enums:
| schema | name | values | owner |
|---|---|---|---|
| public | user_gender_enum | {Male,Female,NonBinary} | root |
UPDATE: Not sure exactly when it was created, however, now I cannot recreate it. Tried deleting the database, and starting the app again, this time the same error occurs, but SHOW ENUMS; reveals nothing
Steps to Reproduce
I have defined the enum like so:
export enum Gender {
Male = 'Male',
Female = 'Female',
NonBinary = 'NonBinary',
}
@Column({
type: 'enum',
enum: Gender,
nullable: true,
})
gender: Gender;My Environment
| Dependency | Version |
|---|---|
| Operating System | |
| Node.js version | 16.14.2 |
| Typescript version | 4.6.3 |
| TypeORM version | 0.2.45 |
| CockroachDB | v21.2 |
Relevant Database Driver(s)
| DB Type | Reproducible |
|---|---|
aurora-mysql |
no |
aurora-postgres |
no |
better-sqlite3 |
no |
cockroachdb |
yes |
cordova |
no |
expo |
no |
mongodb |
no |
mysql |
no |
nativescript |
no |
oracle |
no |
postgres |
no |
react-native |
no |
sap |
no |
spanner |
no |
sqlite |
no |
sqlite-abstract |
no |
sqljs |
no |
sqlserver |
no |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
- ✅ No, I don’t have the time, but I can support (using donations) development.
- ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.