Enhancing Flexibility of CharField Length in SQLite and Exploring Support for Other Databases

Hello everyone,

I recently submitted a PR (#18582) that enhances the flexibility of the CharField length in the SQLite backend by allowing it to be used without explicitly specifying a max_length. This change simplifies development and testing with SQLite, aligning it more closely with PostgreSQL, which already supports this flexibility.

I wanted to initiate a discussion around whether similar flexibility could be introduced for other databases such as MySQL, MariaDB, and Oracle. According to feedback from the PR reviewers, MySQL and MariaDB still require explicit length limits, and while Oracle supports up to 32,767 characters, it too requires an explicit length limit. Currently, it seems that only PostgreSQL and SQLite allow CharField usage without specifying max_length.

For instance, in MySQL versions 5.0.3 and later, VARCHAR fields can support up to 65,535 characters, but still require a defined limit. Would it be possible or practical to introduce more flexible length settings for CharField in these databases, similar to what PostgreSQL and SQLite offer?

I’d love to hear the community’s thoughts on whether there’s interest in adding more flexibility to CharField length configurations across other databases. If there’s positive feedback, I’d be open to creating additional tickets and PRs to explore potential solutions.

Thank you in advance for your feedback and advice! :blush:

I think there’s a bit of confusion here.

Only Postgres and SQLite allow to define varchar without a limit which is the topic of this issue.

The fact MySQL, MariaDB, and Oracle allow for larger than 255 limits has little to do with allowing max_length=None to be specified on SQLite.

1 Like

@charettes I’m sorry for causing confusion. I have marked the related content I posted in the PR as off-topic. Thank you for your feedback :slight_smile: