Repository: django/django
File: django/db/backends/postgresql/features.py (Python)

Code before:
                    # Parameters passed to expressions in SELECT and GROUP BY
                    # clauses are not recognized as the same values when using
                    # server-side binding cursors (#34255).
                    "aggregation.tests.AggregateTestCase."
                    "test_group_by_nested_expression_with_params",
                }
            )
        if not is_psycopg3:
            expected_failures.update(
                {
                    # operator does not exist: bigint[] = integer[]
                    "postgres_tests.test_array.TestQuerying.test_gt",
                    "postgres_tests.test_array.TestQuerying.test_in",
                    "postgres_tests.test_array.TestQuerying.test_lt",
                }
            )
        return expected_failures

    @cached_property
    def uses_server_side_binding(self):
        options = self.connection.settings_dict["OPTIONS"]
        return is_psycopg3 and options.get("server_side_binding") is True

    @cached_property
    def max_query_params(self):
        if self.connection.settings_dict["OPTIONS"].get("server_side_binding"):
            return 2**16 - 1
        return None

    @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,
            "PositiveBigIntegerField": "BigIntegerField",
            "PositiveIntegerField": "IntegerField",
            "PositiveSmallIntegerField": "SmallIntegerField",
        }

    @cached_property
    def is_postgresql_16(self):
        return self.connection.pg_version >= 160000

    @cached_property
    def is_postgresql_17(self):

Review comment (suggestion):
I would just delegate to `uses_server_side_binding` since the added logic is slightly different.

Code after:
                    # Parameters passed to expressions in SELECT and GROUP BY
                    # clauses are not recognized as the same values when using
                    # server-side binding cursors (#34255).
                    "aggregation.tests.AggregateTestCase."
                    "test_group_by_nested_expression_with_params",
                }
            )
        if not is_psycopg3:
            expected_failures.update(
                {
                    # operator does not exist: bigint[] = integer[]
                    "postgres_tests.test_array.TestQuerying.test_gt",
                    "postgres_tests.test_array.TestQuerying.test_in",
                    "postgres_tests.test_array.TestQuerying.test_lt",
                }
            )
        return expected_failures

    @cached_property
    def uses_server_side_binding(self):
        options = self.connection.settings_dict["OPTIONS"]
        return is_psycopg3 and options.get("server_side_binding") is True

    @cached_property
    def max_query_params(self):
        if self.uses_server_side_binding:
            return 2**16 - 1
        return None

    @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,
            "PositiveBigIntegerField": "BigIntegerField",
            "PositiveIntegerField": "IntegerField",
            "PositiveSmallIntegerField": "SmallIntegerField",
        }

    @cached_property
    def is_postgresql_16(self):
        return self.connection.pg_version >= 160000

    @cached_property
    def is_postgresql_17(self):