diff options
author | Adrian Torres <atorresj@redhat.com> | 2022-11-10 19:31:31 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-12-28 12:31:04 +0100 |
commit | 7eee1dca420ee7c4451d24cd32fa08aed0dcbb36 (patch) | |
tree | f643059561e9699cc961845f63faf0a3664ff5d0 /django/db/backends/postgresql/base.py | |
parent | 78f163a4fb3937aca2e71786fbdd51a0ef39629e (diff) | |
download | django-7eee1dca420ee7c4451d24cd32fa08aed0dcbb36.tar.gz |
Fixed #14094 -- Added support for unlimited CharField on PostgreSQL.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'django/db/backends/postgresql/base.py')
-rw-r--r-- | django/db/backends/postgresql/base.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index ceea1bebad..99403f5322 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -80,6 +80,12 @@ from .operations import DatabaseOperations # NOQA isort:skip from .schema import DatabaseSchemaEditor # NOQA isort:skip +def _get_varchar_column(data): + if data["max_length"] is None: + return "varchar" + return "varchar(%(max_length)s)" % data + + class DatabaseWrapper(BaseDatabaseWrapper): vendor = "postgresql" display_name = "PostgreSQL" @@ -92,7 +98,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): "BigAutoField": "bigint", "BinaryField": "bytea", "BooleanField": "boolean", - "CharField": "varchar(%(max_length)s)", + "CharField": _get_varchar_column, "DateField": "date", "DateTimeField": "timestamp with time zone", "DecimalField": "numeric(%(max_digits)s, %(decimal_places)s)", |