diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2022-12-01 20:23:43 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-12-15 06:17:57 +0100 |
commit | 09ffc5c1212d4ced58b708cbbf3dfbfb77b782ca (patch) | |
tree | 15bb8bb049f9339f30d637e78b340473c2038126 /django/db/backends/postgresql/features.py | |
parent | d44ee518c4c110af25bebdbedbbf9fba04d197aa (diff) | |
download | django-09ffc5c1212d4ced58b708cbbf3dfbfb77b782ca.tar.gz |
Fixed #33308 -- Added support for psycopg version 3.
Thanks Simon Charette, Tim Graham, and Adam Johnson for reviews.
Co-authored-by: Florian Apolloner <florian@apolloner.eu>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'django/db/backends/postgresql/features.py')
-rw-r--r-- | django/db/backends/postgresql/features.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/django/db/backends/postgresql/features.py b/django/db/backends/postgresql/features.py index 0eed8c8d63..fd5b05aad4 100644 --- a/django/db/backends/postgresql/features.py +++ b/django/db/backends/postgresql/features.py @@ -1,7 +1,8 @@ import operator -from django.db import InterfaceError +from django.db import DataError, InterfaceError from django.db.backends.base.features import BaseDatabaseFeatures +from django.db.backends.postgresql.psycopg_any import is_psycopg3 from django.utils.functional import cached_property @@ -26,6 +27,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): can_introspect_materialized_views = True can_distinct_on_fields = True can_rollback_ddl = True + schema_editor_uses_clientside_param_binding = True supports_combined_alters = True nulls_order_largest = True closed_cursor_error_class = InterfaceError @@ -82,6 +84,13 @@ class DatabaseFeatures(BaseDatabaseFeatures): } @cached_property + def prohibits_null_characters_in_text_exception(self): + if is_psycopg3: + return DataError, "PostgreSQL text fields cannot contain NUL (0x00) bytes" + else: + return ValueError, "A string literal cannot contain NUL (0x00) characters." + + @cached_property def introspected_field_types(self): return { **super().introspected_field_types, |