﻿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
23318	Management command dbshell does not use DATABASE[...]['OPTIONS'] to set env PGOPTIONS	benjaoming		"I am trying to make use of a different ""search_path"" by use of {{{settings.DATABASE[...]['OPTIONS'] = '-c search_path=my_other_schema,public'}}} -- however, since they are not passed, {{{python manage.py dbshell --database=MY_OTHER_DATABASE_CONNECTION}}} will yield an unexpected result.

The problem is that the shell env variable PGOPTIONS=""-c search_path=MY_SEARCH_PATH_CONF"" is not set.

I am using it for the purpose of having multiple south_migrationhistory tables, one for every database connection. They should have been populated by:

{{{
python manage.py sqlall south | python manage.py dbshell --database=DBNAME
}}}

Current work-around:

{{{
python manage.py sqlall south | PGOPTIONS=""-c search_path=NAME_OF_MY_SCHEMA"" python manage.py dbshell --database=DBNAME
}}}

I am not sure how 1.7 will handle migration histories when populating different database connections and auto-selecting them using routers. But at least having the above to work would be nice, because it makes it easy to manually pipe around the SQL statements to different DB connections.

Also in more severe cases, not having the connection options passed to dbshell might yield other unexpected results!?

This might be of interest to other db backends, but please limit the issue here to only postgres, as it's perfectly simple to copy in the contents of OPTIONS to the env variable PGOPTIONS."	New feature	new	Core (Management commands)	dev	Normal			tomi.kyostila@…	Accepted	1	1	0	1	0	0
