[Django] #34887: Allow unlimited CharField for SQLite backend

43 views
Skip to first unread message

Django

unread,
Oct 4, 2023, 3:29:02 AM10/4/23
to django-...@googlegroups.com
#34887: Allow unlimited CharField for SQLite backend
-----------------------------------------+--------------------------
Reporter: karosis88 | Owner: nobody
Type: New feature | Status: assigned
Component: Uncategorized | Version: 4.2
Severity: Normal | Keywords: SQLite
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+--------------------------
Model validation throws an error on CharField when the max_length argument
is not specified.

{{{#!python
class MyModel(models.Model):
name = models.CharField()
}}}

The developer who knows that SQLite can store unlimited characters would
be surprised in such cases.
I suggest allowing unlimited characters for SQLite, like we do for
PostgreSQL.

Relevant PostgreSQL ticket: https://code.djangoproject.com/ticket/14094

--
Ticket URL: <https://code.djangoproject.com/ticket/34887>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 4, 2023, 3:29:28 AM10/4/23
to django-...@googlegroups.com
#34887: Allow unlimited CharField for SQLite backend
-------------------------------+-----------------------------------------
Reporter: Kar Petrosyan | Owner: Kar Petrosyan

Type: New feature | Status: assigned
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution:

Keywords: SQLite | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------------
Changes (by Kar Petrosyan):

* owner: nobody => Kar Petrosyan


--
Ticket URL: <https://code.djangoproject.com/ticket/34887#comment:1>

Django

unread,
Oct 4, 2023, 3:42:49 AM10/4/23
to django-...@googlegroups.com
#34887: Allow unlimited CharField for SQLite backend
-------------------------------------+-------------------------------------

Reporter: Kar Petrosyan | Owner: Kar
| Petrosyan
Type: New feature | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: wontfix

Keywords: SQLite | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: assigned => closed
* resolution: => wontfix
* component: Uncategorized => Database layer (models, ORM)


Comment:

SQLite has limited number of datatypes, and there is no difference between
`TEXT` and `VARCHAR` (no declared max length), both would be stored in the
`TEXT` datatype. You can use `TextField` for unlimited `CharField`.

--
Ticket URL: <https://code.djangoproject.com/ticket/34887#comment:2>

Django

unread,
Oct 4, 2023, 4:06:34 AM10/4/23
to django-...@googlegroups.com
#34887: Allow unlimited CharField for SQLite backend
-------------------------------------+-------------------------------------
Reporter: karosis88 | Owner: karosis88

Type: New feature | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: SQLite | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by karosis88):

Replying to [comment:2 Mariusz Felisiak]:


> SQLite has limited number of datatypes, and there is no difference
between `TEXT` and `VARCHAR` (no declared max length), both would be
stored in the `TEXT` datatype. You can use `TextField` for unlimited
`CharField`.

Does it really solve the problem? I want to use CharField and not
TextField (when using sqlite3 for the startup but planning to migrate to
another DBMS).
In such cases, I can use CharField (max_length = 1), but it wouldn't make
any sense for the reviewer.

--
Ticket URL: <https://code.djangoproject.com/ticket/34887#comment:3>

Django

unread,
Oct 4, 2023, 4:28:21 AM10/4/23
to django-...@googlegroups.com
#34887: Allow unlimited CharField for SQLite backend
-------------------------------------+-------------------------------------
Reporter: Kar Petrosyan | Owner: Kar
| Petrosyan
Type: New feature | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: SQLite | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:3 karosis88]:


> Does it really solve the problem?

Yes.

> I want to use CharField and not TextField (when using sqlite3 for the
startup but planning to migrate to another DBMS).
> In such cases, I can use CharField (max_length = 1), but it wouldn't
make any sense for the reviewer.

There is no way to switch between databases without changing anything.
It's recommended to use the same database in development and production
environments, unless you're aware of all migration caveats. We accepted
#14094, because `CharField` and `TextField` use different datatypes on
PostgreSQL.

--
Ticket URL: <https://code.djangoproject.com/ticket/34887#comment:4>

Django

unread,
Sep 13, 2024, 10:43:22 AM9/13/24
to django-...@googlegroups.com
#34887: Allow unlimited CharField for SQLite backend
-------------------------------------+-------------------------------------
Reporter: Kar Petrosyan | Owner: Kar
| Petrosyan
Type: New feature | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: SQLite | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

For the record I've opted into accepting this feature in
ticket:35759#comment:6 as to me the situation on SQLite is similar to
Postgres.

On SQLite both `varchar` and `text` are an alias for the same internal
type but it's also the case on Postgres where
[https://www.depesz.com/2010/03/02/charx-vs-varcharx-vs-varchar-vs-text/
they are aliases] for `varlena`).

The lack of constraint enforcement on SQLite is a distinct problem (see
#21471) that allowing `max_length=None` could help solving by providing a
way to restore the previous behaviour for users that need it.
--
Ticket URL: <https://code.djangoproject.com/ticket/34887#comment:5>

Django

unread,
Sep 16, 2024, 4:49:01 AM9/16/24
to django-...@googlegroups.com
#34887: Allow unlimited CharField for SQLite backend
-------------------------------------+-------------------------------------
Reporter: Kar Petrosyan | Owner: Kar
| Petrosyan
Type: New feature | Status: new
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* has_patch: 0 => 1
* resolution: wontfix =>
* stage: Unreviewed => Accepted
* status: closed => new

Comment:

#35759 was a duplicate - reopening and accepting
--
Ticket URL: <https://code.djangoproject.com/ticket/34887#comment:6>

Django

unread,
Sep 16, 2024, 4:49:17 AM9/16/24
to django-...@googlegroups.com
#34887: Allow unlimited CharField for SQLite backend
-------------------------------------+-------------------------------------
Reporter: Kar Petrosyan | Owner: Jae Hyuck
| Sa
Type: New feature | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* owner: Kar Petrosyan => Jae Hyuck Sa
* status: new => assigned

Comment:

[https://github.com/django/django/pull/18582 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/34887#comment:7>

Django

unread,
Sep 16, 2024, 4:51:21 AM9/16/24
to django-...@googlegroups.com
#34887: Allow unlimited CharField for SQLite backend
-------------------------------------+-------------------------------------
Reporter: Kar Petrosyan | Owner: Jae Hyuck
| Sa
Type: New feature | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/34887#comment:8>

Django

unread,
Sep 16, 2024, 7:31:15 AM9/16/24
to django-...@googlegroups.com
#34887: Allow unlimited CharField for SQLite backend
-------------------------------------+-------------------------------------
Reporter: Kar Petrosyan | Owner: Jae Hyuck
| Sa
Type: New feature | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: SQLite | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"fd92f247891950bc92369b2457e032ec11f0147d" fd92f24]:
{{{#!CommitTicketReference repository=""
revision="fd92f247891950bc92369b2457e032ec11f0147d"
Fixed #34887 -- Added support for unlimited models.CharField on SQLite.

Signed-off-by: saJaeHyukc <wogur...@gmail.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34887#comment:9>
Reply all
Reply to author
Forward
0 new messages