From 79a965f3285f5fe9dcb7b4ed55786be57c6fff51 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..786a50b 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', []): + cursor.execute(statement) yield cursor diff --git a/tests/settings.py b/tests/settings.py index 5e7ac02..e2b5c3d 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -1 +1,4 @@ BIJOE_CACHE = False +BIJOE_INIT_SQL = [ + 'SET lc_time = \'fr_FR.UTF-8\'', +] -- 2.23.0