From 3c4ba0c379c4f9c5b0fd6434f86c86ad6b13076a Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 12 Dec 2019 14:43:42 +0100 Subject: [PATCH] engine: add setting for postgresql init statements (#38462) --- bijoe/engine.py | 3 +++ tests/settings.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/bijoe/engine.py b/bijoe/engine.py index 4fd193a..1265c3a 100644 --- a/bijoe/engine.py +++ b/bijoe/engine.py @@ -23,6 +23,7 @@ import hashlib import psycopg2 from django.core.cache import cache +from django.conf import settings from django.utils.translation import ugettext_lazy as _ from . import schemas @@ -526,4 +527,6 @@ class Engine(object): with connection.cursor() as cursor: search_path = ', '.join(['%s' % namespace for namespace in self.warehouse.search_path]) cursor.execute('SET SEARCH_PATH = %s' % search_path) + for statement in getattr(settings, 'BIJOE_INIT_SQL') or []: + cursor.execute(statement) yield cursor diff --git a/tests/settings.py b/tests/settings.py index 5e7ac02..39aa7ce 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -1 +1,4 @@ BIJOE_CACHE = False +BIJOE_INIT_SQL = [ + 'SET lc_time \'fr_FR\'', +] -- 2.23.0