Ticket #5435: no_need_for_db_user.patch

File no_need_for_db_user.patch, 1.4 KB (added by Robert Coup, 17 years ago)
  • django/contrib/gis/db/backend/postgis/creation.py

     
    2828
    2929    # Constructing the necessary SQL to create the database (the DATABASE_USER
    3030    #  must possess the privileges to create a database)
    31     create_sql = 'CREATE DATABASE %s OWNER %s' % (connection.ops.quote_name(db_name),
    32                                                   settings.DATABASE_USER)
     31    create_sql = 'CREATE DATABASE %s' % connection.ops.quote_name(db_name)
     32    if settings.DATABASE_USER:
     33        create_sql += ' OWNER %s' % settings.DATABASE_USER
     34       
    3335    cursor = connection.cursor()
    3436    _set_autocommit(connection)
    3537
     
    133135def get_cmd_options(db_name):
    134136    "Obtains the command-line PostgreSQL connection options for shell commands."
    135137    # The db_name parameter is optional
     138    options = ''
    136139    if db_name:
    137         options = '-d %s -U %s ' % (db_name, settings.DATABASE_USER)
    138     else:
    139         options = '-U %s ' % settings.DATABASE_USER
     140        options += '-d %s ' % db_name
     141    if settings.DATABASE_USER:
     142        options += '-U %s ' % settings.DATABASE_USER
    140143    if settings.DATABASE_HOST:
    141144        options += '-h %s ' % settings.DATABASE_HOST
    142145    if settings.DATABASE_PORT:
Back to Top