You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Set @Column() default db type for string properties to 'text' instead of 'varchar' #7979
Set @column() default db type for string properties to 'text' instead of 'varchar'
What was unclear or otherwise insufficient?
Is is possible to change the TypeOrm default db types for string properties? The documentation makes no mention but I assume each driver has its own definitions of what primitive types match what db types.
@Xzas22 You can have that done in an hour, maybe two and it is a one time job.
If you want you can modify the driver locally here and then use it, but you will have to maintain it. Keep in mind that there is no guarantee that something else won't break because of this.
If you asking about changing default behavior - no, we can't do that because using text is limiting your strings in a number of ways and you'll have different performance problems with this approach.
If you asking about providing a special configuration for such purpose - then answer is no, we can't do that because it is too specific request.
@blazmrak provided a good solution for your request. You can also create your "own column decorator" that simply calls default "Column" decorator, but with type set to text.
@pleerock I'm afraid they were not asking to change it in the library itself, but rather an option for devs to configure what should be the default db type for string (or even number?) in their own project.
Would it be possible to at least provide an option for us to override that? I'm currently using custom decorators as you suggested, but I wanted new devs joining the team to have a smoother onboarding being able to use TypeORM as it is, without having to think about custom decorators, and coming from Entity Framework for C# I really miss this feature.
Activity
amittal-quot commentedon Jul 30, 2021
you can use
@column({type:"text"})MWhite-22 commentedon Jul 30, 2021
I know I can for individual columns but I have 45 tables, some with 20+ columns.
I want to change the typeorm setting that makes decorating a string property with a normal @column() decorator default to ‘text’
blazmrak commentedon Aug 1, 2021
@Xzas22 You can have that done in an hour, maybe two and it is a one time job.
If you want you can modify the driver locally here and then use it, but you will have to maintain it. Keep in mind that there is no guarantee that something else won't break because of this.
pleerock commentedon Aug 2, 2021
If you asking about changing default behavior - no, we can't do that because using
textis limiting your strings in a number of ways and you'll have different performance problems with this approach.If you asking about providing a special configuration for such purpose - then answer is no, we can't do that because it is too specific request.
@blazmrak provided a good solution for your request. You can also create your "own column decorator" that simply calls default "Column" decorator, but with type set to
text.AlissonRS commentedon Jul 22, 2022
@pleerock I'm afraid they were not asking to change it in the library itself, but rather an option for devs to configure what should be the default db type for string (or even number?) in their own project.
I agree that
texthas limitations, but so doesvarchar. In my project I'd like all string columns to benvarcharby default as it avoids a lot of pain when dealing with unicode characters, please check the most upvoted answer here for the rationale: https://stackoverflow.com/questions/144283/what-is-the-difference-between-varchar-and-nvarcharWould it be possible to at least provide an option for us to override that? I'm currently using custom decorators as you suggested, but I wanted new devs joining the team to have a smoother onboarding being able to use TypeORM as it is, without having to think about custom decorators, and coming from Entity Framework for C# I really miss this feature.
Thanks and I appreciate this great library!!!