mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Infer text column from string property when there is no length #6965
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Tobion on GitHub (Apr 24, 2022).
Feature Request
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.