mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Refs #28334 -- Fixed crash in hstore/citext oid caching during test db creation.
This commit is contained in:
parent
e7adad27f3
commit
f7b0532ec0
@ -5,6 +5,7 @@ from psycopg2 import ProgrammingError
|
|||||||
from psycopg2.extras import register_hstore
|
from psycopg2.extras import register_hstore
|
||||||
|
|
||||||
from django.db import connections
|
from django.db import connections
|
||||||
|
from django.db.backends.base.base import NO_DB_ALIAS
|
||||||
|
|
||||||
|
|
||||||
@functools.lru_cache()
|
@functools.lru_cache()
|
||||||
@ -34,7 +35,7 @@ def get_citext_oids(connection_alias):
|
|||||||
|
|
||||||
|
|
||||||
def register_type_handlers(connection, **kwargs):
|
def register_type_handlers(connection, **kwargs):
|
||||||
if connection.vendor != 'postgresql':
|
if connection.vendor != 'postgresql' or connection.alias == NO_DB_ALIAS:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -3,7 +3,9 @@ from django.db import connection
|
|||||||
from . import PostgreSQLTestCase
|
from . import PostgreSQLTestCase
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from django.contrib.postgres.signals import get_hstore_oids, get_citext_oids
|
from django.contrib.postgres.signals import (
|
||||||
|
get_citext_oids, get_hstore_oids, register_type_handlers,
|
||||||
|
)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass # pyscogp2 isn't installed.
|
pass # pyscogp2 isn't installed.
|
||||||
|
|
||||||
@ -31,3 +33,7 @@ class OIDTests(PostgreSQLTestCase):
|
|||||||
def test_citext_values(self):
|
def test_citext_values(self):
|
||||||
oids = get_citext_oids(connection.alias)
|
oids = get_citext_oids(connection.alias)
|
||||||
self.assertOIDs(oids)
|
self.assertOIDs(oids)
|
||||||
|
|
||||||
|
def test_register_type_handlers_no_db(self):
|
||||||
|
"""Registering type handlers for the nodb connection does nothing."""
|
||||||
|
register_type_handlers(connection._nodb_connection)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user