Infer text column from string property when there is no length #6965

Open
opened 2026-01-22 15:42:13 +01:00 by admin · 0 comments
Owner

Originally created by @Tobion on GitHub (Apr 24, 2022).

Feature Request

Q A
New Feature yes
RFC yes
BC Break yes

Summary

In DBAL 4.x the length will usually be required for varchar columns due to 3263
This is a good thing. But one thing might be unfortunate. When inferring the type from property types (feature https://github.com/doctrine/orm/issues/7939), string type is mapped to varchar. So when people use a string property but do not specify a length, it will work in Postgress (varchar without length equals text type) but will fail in MySQL and other RDBMS.
Given that this is a common case and people usually don't really care about the length of a string unless there are some specific requirements, I think this could be improved.

So I would suggest to change the inferred type for a string property to TEXT type when there a no length. If there is a length and it is supported by VARCHAR, it could stay to be varchar. This way inferred type is more clever depending on the length and it works without a failure by default.
As this would be a BC break given the column type changes in some cases, this could only be done in ORM 3.0 I assume.

Originally created by @Tobion on GitHub (Apr 24, 2022). ### Feature Request <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | New Feature | yes | RFC | yes | BC Break | yes #### Summary In DBAL 4.x the length will usually be required for varchar columns due to [3263](https://github.com/doctrine/dbal/pull/3586) This is a good thing. But one thing might be unfortunate. When inferring the type from property types (feature https://github.com/doctrine/orm/issues/7939), string type is mapped to varchar. So when people use a string property but do not specify a length, it will work in Postgress (varchar without length equals text type) but will fail in MySQL and other RDBMS. Given that this is a common case and people usually don't really care about the length of a string unless there are some specific requirements, I think this could be improved. So I would suggest to change the inferred type for a string property to TEXT type when there a no length. If there is a length and it is supported by VARCHAR, it could stay to be varchar. This way inferred type is more clever depending on the length and it works without a failure by default. As this would be a BC break given the column type changes in some cases, this could only be done in ORM 3.0 I assume.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6965