comparison roundup/backends/back_postgresql.py @ 4515:6467fd9a3afd

The PostgreSQL backend quotes database names now for CREATE and DROP... ...enabling more exotic tracker names. Closes issue2550497. Thanks to Sebastian Harl for providing the patch.
author Bernhard Reiter <Bernhard.Reiter@intevation.de>
date Fri, 01 Jul 2011 15:17:32 +0000
parents f6c49df25048
children 6e3e4f24c753
comparison
equal deleted inserted replaced
4514:f6c49df25048 4515:6467fd9a3afd
33 del d['read_default_file'] 33 del d['read_default_file']
34 return d 34 return d
35 35
36 def db_create(config): 36 def db_create(config):
37 """Clear all database contents and drop database itself""" 37 """Clear all database contents and drop database itself"""
38 command = "CREATE DATABASE %s WITH ENCODING='UNICODE'"%config.RDBMS_NAME 38 command = "CREATE DATABASE \"%s\" WITH ENCODING='UNICODE'"%config.RDBMS_NAME
39 if config.RDBMS_TEMPLATE : 39 if config.RDBMS_TEMPLATE :
40 command = command + " TEMPLATE=%s" % config.RDBMS_TEMPLATE 40 command = command + " TEMPLATE=%s" % config.RDBMS_TEMPLATE
41 logging.getLogger('roundup.hyperdb').info(command) 41 logging.getLogger('roundup.hyperdb').info(command)
42 db_command(config, command) 42 db_command(config, command)
43 43
44 def db_nuke(config, fail_ok=0): 44 def db_nuke(config, fail_ok=0):
45 """Clear all database contents and drop database itself""" 45 """Clear all database contents and drop database itself"""
46 command = 'DROP DATABASE %s'% config.RDBMS_NAME 46 command = 'DROP DATABASE "%s"'% config.RDBMS_NAME
47 logging.getLogger('roundup.hyperdb').info(command) 47 logging.getLogger('roundup.hyperdb').info(command)
48 db_command(config, command) 48 db_command(config, command)
49 49
50 if os.path.exists(config.DATABASE): 50 if os.path.exists(config.DATABASE):
51 shutil.rmtree(config.DATABASE) 51 shutil.rmtree(config.DATABASE)

Roundup Issue Tracker: http://roundup-tracker.org/