﻿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
26096	Django 1.9.1 sometimes fails to delete cloned testing postgres db	Alex Krupp	nobody	"I got this error running python manage.py test tests --parallel=2:

“Got an error cloning the test database: unorderable types: str() >= int()”

This continued happening when running the tests in parallel even when telling django to delete the existing db, but not when using --parallel=1.

The full traceback is:

{{{
Type 'yes' if you would like to try deleting the test database 'test_myapp_api', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Cloning test database for alias 'default'...
Got an error cloning the test database: unorderable types: str() >= int()
Traceback (most recent call last):
  File ""/home/vagrant/user/.pyenv/versions/myapp343/lib/python3.4/site-packages/django/db/backends/utils.py"", line 62, in execute
    return self.cursor.execute(sql)
psycopg2.ProgrammingError: database ""test_myapp_api_1"" already exists
 
The above exception was the direct cause of the following exception:
 
Traceback (most recent call last):
  File ""/home/vagrant/user/.pyenv/versions/myapp343/lib/python3.4/site-packages/django/db/backends/postgresql/creation.py"", line 29, in _clone_test_db
    qn(target_database_name), qn(source_database_name)))
  File ""/home/vagrant/user/.pyenv/versions/myapp343/lib/python3.4/site-packages/django/db/backends/utils.py"", line 64, in execute
    return self.cursor.execute(sql, params)
  File ""/home/vagrant/user/.pyenv/versions/myapp343/lib/python3.4/site-packages/django/db/utils.py"", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File ""/home/vagrant/user/.pyenv/versions/myapp343/lib/python3.4/site-packages/django/utils/six.py"", line 685, in reraise
    raise value.with_traceback(tb)
  File ""/home/vagrant/user/.pyenv/versions/myapp343/lib/python3.4/site-packages/django/db/backends/utils.py"", line 62, in execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: database ""test_myapp_api_1"" already exists
 
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File ""/home/vagrant/user/.pyenv/versions/myapp343/lib/python3.4/site-packages/django/db/backends/postgresql/creation.py"", line 36, in _clone_test_db
    self._get_database_display_str(target_database_name, verbosity),
  File ""/home/vagrant/user/.pyenv/versions/myapp343/lib/python3.4/site-packages/django/db/backends/base/creation.py"", line 140, in _get_database_display_str
    ("" ('%s')"" % database_name) if verbosity >= 2 else '',
TypeError: unorderable types: str() >= int()
}}}

My stack: Django 1.9.1, Postgres 9.4, ubuntu trusty-64"	Bug	new	Uncategorized	1.9	Normal		testing parallel		Unreviewed	0	0	0	0	0	0
