From 77aa74cb70dd85497dbade6bc0f394aa41e88c94 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 7 Nov 2019 01:26:22 -0800 Subject: Refs #29983 -- Added support for using pathlib.Path in all settings. --- django/db/backends/sqlite3/base.py | 4 +++- django/db/backends/sqlite3/creation.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'django/db/backends/sqlite3') diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 45a22f5a36..51a15ee10a 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -174,7 +174,9 @@ class DatabaseWrapper(BaseDatabaseWrapper): "settings.DATABASES is improperly configured. " "Please supply the NAME value.") kwargs = { - 'database': settings_dict['NAME'], + # TODO: Remove str() when dropping support for PY36. + # https://bugs.python.org/issue33496 + 'database': str(settings_dict['NAME']), 'detect_types': Database.PARSE_DECLTYPES | Database.PARSE_COLNAMES, **settings_dict['OPTIONS'], } diff --git a/django/db/backends/sqlite3/creation.py b/django/db/backends/sqlite3/creation.py index 3fcf668ced..d97052f52d 100644 --- a/django/db/backends/sqlite3/creation.py +++ b/django/db/backends/sqlite3/creation.py @@ -1,6 +1,7 @@ import os import shutil import sys +from pathlib import Path from django.db.backends.base.creation import BaseDatabaseCreation @@ -9,7 +10,9 @@ class DatabaseCreation(BaseDatabaseCreation): @staticmethod def is_in_memory_db(database_name): - return database_name == ':memory:' or 'mode=memory' in database_name + return not isinstance(database_name, Path) and ( + database_name == ':memory:' or 'mode=memory' in database_name + ) def _get_test_db_name(self): test_database_name = self.connection.settings_dict['TEST']['NAME'] or ':memory:' -- cgit v1.3