Django

Code

Changeset 6238

Show
Ignore:
Timestamp:
09/14/07 17:40:13 (1 year ago)
Author:
jbronn
Message:

gis: Fixed #5435 with patch from rcoup.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/db/backend/postgis/creation.py

    r6026 r6238  
    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) 
     
    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