mirror of https://github.com/django/django.git
Fixed #34887 -- Added support for unlimited models.CharField on SQLite.
Signed-off-by: saJaeHyukc <wogur981208@gmail.com>
This commit is contained in:
parent
121747fdba
commit
fd92f24789
|
@ -40,6 +40,12 @@ def adapt_datetime(val):
|
||||||
return val.isoformat(" ")
|
return val.isoformat(" ")
|
||||||
|
|
||||||
|
|
||||||
|
def _get_varchar_column(data):
|
||||||
|
if data["max_length"] is None:
|
||||||
|
return "varchar"
|
||||||
|
return "varchar(%(max_length)s)" % data
|
||||||
|
|
||||||
|
|
||||||
Database.register_converter("bool", b"1".__eq__)
|
Database.register_converter("bool", b"1".__eq__)
|
||||||
Database.register_converter("date", decoder(parse_date))
|
Database.register_converter("date", decoder(parse_date))
|
||||||
Database.register_converter("time", decoder(parse_time))
|
Database.register_converter("time", decoder(parse_time))
|
||||||
|
@ -62,7 +68,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||||
"BigAutoField": "integer",
|
"BigAutoField": "integer",
|
||||||
"BinaryField": "BLOB",
|
"BinaryField": "BLOB",
|
||||||
"BooleanField": "bool",
|
"BooleanField": "bool",
|
||||||
"CharField": "varchar(%(max_length)s)",
|
"CharField": _get_varchar_column,
|
||||||
"DateField": "date",
|
"DateField": "date",
|
||||||
"DateTimeField": "datetime",
|
"DateTimeField": "datetime",
|
||||||
"DecimalField": "decimal",
|
"DecimalField": "decimal",
|
||||||
|
|
|
@ -60,6 +60,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||||
"""
|
"""
|
||||||
insert_test_table_with_defaults = 'INSERT INTO {} ("null") VALUES (1)'
|
insert_test_table_with_defaults = 'INSERT INTO {} ("null") VALUES (1)'
|
||||||
supports_default_keyword_in_insert = False
|
supports_default_keyword_in_insert = False
|
||||||
|
supports_unlimited_charfield = True
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def django_test_skips(self):
|
def django_test_skips(self):
|
||||||
|
|
|
@ -720,8 +720,8 @@ The default form widget for this field is a :class:`~django.forms.TextInput`.
|
||||||
The maximum length (in characters) of the field. The ``max_length``
|
The maximum length (in characters) of the field. The ``max_length``
|
||||||
is enforced at the database level and in Django's validation using
|
is enforced at the database level and in Django's validation using
|
||||||
:class:`~django.core.validators.MaxLengthValidator`. It's required for all
|
:class:`~django.core.validators.MaxLengthValidator`. It's required for all
|
||||||
database backends included with Django except PostgreSQL, which supports
|
database backends included with Django except PostgreSQL and SQLite, which
|
||||||
unlimited ``VARCHAR`` columns.
|
supports unlimited ``VARCHAR`` columns.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
@ -730,6 +730,10 @@ The default form widget for this field is a :class:`~django.forms.TextInput`.
|
||||||
``max_length`` for some backends. Refer to the :doc:`database backend
|
``max_length`` for some backends. Refer to the :doc:`database backend
|
||||||
notes </ref/databases>` for details.
|
notes </ref/databases>` for details.
|
||||||
|
|
||||||
|
.. versionchanged:: 5.2
|
||||||
|
|
||||||
|
Support for unlimited ``VARCHAR`` columns was added on SQLite.
|
||||||
|
|
||||||
.. attribute:: CharField.db_collation
|
.. attribute:: CharField.db_collation
|
||||||
|
|
||||||
Optional. The database collation name of the field.
|
Optional. The database collation name of the field.
|
||||||
|
|
|
@ -223,6 +223,10 @@ Models
|
||||||
expression contains a set-returning function, enforcing subquery evaluation.
|
expression contains a set-returning function, enforcing subquery evaluation.
|
||||||
This is necessary for many Postgres set-returning functions.
|
This is necessary for many Postgres set-returning functions.
|
||||||
|
|
||||||
|
* :attr:`CharField.max_length <django.db.models.CharField.max_length>` is no
|
||||||
|
longer required to be set on SQLite, which supports unlimited ``VARCHAR``
|
||||||
|
columns.
|
||||||
|
|
||||||
Requests and Responses
|
Requests and Responses
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue