Ticket #1051: ticket_1051_rev6669.diff

File ticket_1051_rev6669.diff, 4.4 KB (added by roppert, 7 years ago)

Patche done against rev 6669

  • django/conf/project_template/settings.py

     
    1111
    1212DATABASE_ENGINE = ''           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
    1313DATABASE_NAME = ''             # Or path to database file if using sqlite3.
     14DATABASE_SCHEMAS = ''          # Databse schemas to be used. Only used in PostgreSQL
    1415DATABASE_USER = ''             # Not used with sqlite3.
    1516DATABASE_PASSWORD = ''         # Not used with sqlite3.
    1617DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
  • django/conf/global_settings.py

     
    112112# Database connection info.
    113113DATABASE_ENGINE = ''           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
    114114DATABASE_NAME = ''             # Or path to database file if using sqlite3.
     115DATABASE_SCHEMAS = ''          # Databse schemas to be used. Only used in PostgreSQL
    115116DATABASE_USER = ''             # Not used with sqlite3.
    116117DATABASE_PASSWORD = ''         # Not used with sqlite3.
    117118DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
  • django/db/backends/postgresql/base.py

     
    8181
    8282    def _cursor(self, settings):
    8383        set_tz = False
     84        set_path = False
    8485        if self.connection is None:
    8586            set_tz = True
    8687            if settings.DATABASE_NAME == '':
     
    9596                conn_string += " host=%s" % settings.DATABASE_HOST
    9697            if settings.DATABASE_PORT:
    9798                conn_string += " port=%s" % settings.DATABASE_PORT
     99            if settings.DATABASE_SCHEMAS:
     100                set_path = True
    98101            self.connection = Database.connect(conn_string, **self.options)
    99102            self.connection.set_isolation_level(1) # make transactions transparent to all cursors
    100103        cursor = self.connection.cursor()
    101104        if set_tz:
    102105            cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
     106        if set_path:
     107            cursor.execute("SET search_path TO %s" % ','.join(settings.DATABASE_SCHEMAS))
    103108        cursor.execute("SET client_encoding to 'UNICODE'")
    104109        cursor = UnicodeCursorWrapper(cursor, 'utf-8')
    105110        return cursor
  • django/db/backends/postgresql_psycopg2/base.py

     
    5050
    5151    def _cursor(self, settings):
    5252        set_tz = False
     53        set_path = False
    5354        if self.connection is None:
    5455            set_tz = True
    5556            if settings.DATABASE_NAME == '':
     
    6465                conn_string += " host=%s" % settings.DATABASE_HOST
    6566            if settings.DATABASE_PORT:
    6667                conn_string += " port=%s" % settings.DATABASE_PORT
     68            if settings.DATABASE_SCHEMAS:
     69                set_path = True
    6770            self.connection = Database.connect(conn_string, **self.options)
    6871            self.connection.set_isolation_level(1) # make transactions transparent to all cursors
    6972            self.connection.set_client_encoding('UTF8')
     
    7174        cursor.tzinfo_factory = None
    7275        if set_tz:
    7376            cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
     77        if set_path:
     78            cursor.execute("SET search_path TO %s" % ','.join(settings.DATABASE_SCHEMAS))
    7479        return cursor
  • docs/settings.txt

     
    322322
    323323The username to use when connecting to the database. Not used with SQLite.
    324324
     325DATABASE_SCHEMAS
     326----------------
     327
     328Default: ``''`` (Empty string)
     329
     330On databases supporting schemas this is the schemas to be used.
     331
     332Note that currently the only backend with schema support is PostgreSQL.
     333
    325334DATE_FORMAT
    326335-----------
    327336
Back to Top