Added simple-enum column type#3700
Added simple-enum column type#3700pleerock merged 2 commits intotypeorm:masterfrom borremosch:add-simple-enum-type
Conversation
| } else if (columnMetadata.type === "simple-json") { | ||
| value = DateUtils.stringToSimpleJson(value); | ||
|
|
||
| } else if ( columnMetadata.type === "simple-enum" ) { |
There was a problem hiding this comment.
since sqlite supports enum now, it should have enum type as well
There was a problem hiding this comment.
also, don't forget to list new types in the docs (website)
There was a problem hiding this comment.
or using CHECK constraint in sqlite can't be called enum ?
There was a problem hiding this comment.
I cannot find native enum support on the SQLite website: https://www.sqlite.org/datatype3.html.
I would say it makes sense to have enum for native enum types, and simple-enum for the emulated enum type. That way it will be more clear when you are using a derived/emulated type.
There was a problem hiding this comment.
There is currently no section on either enums or simple- types on the website. Do you want me to create one in a pull request?
Also, are you aware that the website certificate is invalid when accessing it from https://typeorm.io/?
There was a problem hiding this comment.
Also, are you aware that the website certificate is invalid when accessing it from https://typeorm.io/?
yes =(
There is currently no section on either enums or
simple-types on the website. Do you want me to create one in a pull request?
yes feel free please
There was a problem hiding this comment.
2 other simple- types are now mentioned, but simple-enum is not:
https://typeorm.io/entities#simple-array-column-type
#10077
|
Great work! Asking @AlexMesser for review |
|
Thank you so much! |
|
@borremosch thanks! :) |
|
Found a bug in this PR, that prevents me from using a protected word like "from" as the column name. For example: export enum FromType {
NO_REPLY = 'no-reply',
RANDOM = 'random',
}
@Entity('broadcast')
class BroadcastEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({
type: 'simple-enum',
enum: FromType,
nullable: false,
})
from: FromType;
}Here's the error: As you can see, the generated column: It should look like this: (The column name must be wrapped in double-quotes.) This was in sqlite, if that matters. |
|
When using simple-enum and using 'synchronise' in the connection options i get a continuous "column has changed errors" (i.e. it keeps ALTER table). Removing it naturally removes the CHECK IN feature but there is some error in detecting if a column schema is the same and should be altered. This is in TypeORM 0.2.25 and SQLite 3 adapter 4.2.0. |
I have added the
simple-enumcolumn type discussed in #1414. It works like this:ENUMtype is usedCHECK()constraint is used, like so:ENUMtype, I believesimple-enumshould be based on it. I have not addedsimple-enumfor Oracle.