﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10452	geodjango test runner database creation error handling	Charlie DeTar	nobody	"The geodjango testrunner assumes that any failure at database creation is the result of the database already existing, resulting in the message:

{{{
It appears that the database, test_foobar, already exists.  Type 'yes' to delete it, or 'no' to cancel:
}}}

This message appears even when the test database does not exist.  If one types ""yes"", the test runner attempts to drop the non-existent database and errors out, hiding the actual error that prevented database creation.

One example of another reason the database creation might fail is if the user does not have copy privileges for the template database.
When using the ""POSTGIS_TEMPLATE"" setting, the geodjango testrunner attempts to copy the template database to create the new test database.  Without copy privileges, this fails.  In postgresql, if the database user is not the owner of POSTGIS_TEMPLATE, the user will not have copy privileges unless ""datistemplate"" is set to ""true"" for the template database.

A couple ways to improve this situation:

1. Improving the documentation to indicate that when setting up the template database, it is necessary to set ""datistemplate"" to true, for example:  
{{{
UPDATE pg_database SET datistemplate = true WHERE datname = 'template_postgis';
}}}

2. Checking to see if the error in database creation is actually a result of there being a pre-existing table, and if not, giving a more appropriate error message.

3. Changing the ""DROP DATABASE"" query to an appropriate ""DROP DATABASE IF EXISTS"" type query, with the assumption that any further creation error should do the right thing."		closed	GIS	dev		duplicate	geodjango test errors documentation		Unreviewed	0	0	0	0	0	0
