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.
--
Ticket URL: <https://code.djangoproject.com/ticket/23318>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Database layer (models, ORM) => Core (Management commands)
* needs_tests: => 0
* needs_docs: => 0
* type: Bug => New feature
* stage: Unreviewed => Accepted
Comment:
It looks like a reasonable request, and we recently enhanced the options
that dbshell accepts when using MySQL (#22646).
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:1>
* owner: nobody => fcurella
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:2>
* has_patch: 0 => 1
* version: 1.7-rc-2 => master
* easy: 0 => 1
Comment:
PR up at https://github.com/django/django/pull/3168
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:3>
* needs_better_patch: 0 => 1
* easy: 1 => 0
Comment:
I left comments for improvement on the PR. Please uncheck "Patch needs
improvement" when you update it, thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:4>
* cc: tomi.kyostila@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:5>
Comment (by Dulmandakh):
PR https://github.com/django/django/pull/12715
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:6>
Comment (by Dulmandakh):
The implementation differs from initial implementation because OPTIONS may
be used to set many connection configurations of psycopg2 other than
**options** or PGOPTIONS.
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:7>
Comment (by felixxm):
Replying to [comment:7 Dulmandakh]:
> .... may be used to set many connection configurations of psycopg2 other
than **options** or PGOPTIONS.
I'm not sure what does it mean? You want to pass `options` to the
`PGOPTIONS` so how it can support sth else? The list of all available
options can be found in [https://www.postgresql.org/docs/10/runtime-
config.html the PostgreSQL docs]. Also I'm not sure
([https://github.com/django/django/pull/3168#issuecomment-55174417 as
pointed by Tim]) if passing all possible options is safe.
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:8>
Comment (by Dulmandakh):
Replying to [comment:8 felixxm]:
> Replying to [comment:7 Dulmandakh]:
> > .... may be used to set many connection configurations of psycopg2
other than **options** or PGOPTIONS.
>
> I'm not sure what does it mean? You want to pass `options` to the
`PGOPTIONS` so how it can support sth else? The list of all available
options can be found in [https://www.postgresql.org/docs/10/runtime-
config.html the PostgreSQL docs]. Also I'm not sure
([https://github.com/django/django/pull/3168#issuecomment-55174417 as
pointed by Tim]) if passing all possible options is safe.
IIRC, OPTIONS passed to
[https://www.psycopg.org/docs/module.html#psycopg2.connect
psycopg2.connect] method directly as a part of kwargs, so it might be best
to not interfere with it. Also we cannot determine which options are safe
or not, so it might be best to leave it a web developer to decide.
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:9>
* owner: Flavio Curella => Dulmandakh
* needs_better_patch: 1 => 0
Comment:
Improvement flag was set on previous patch, so unsetting for new patch and
assigning to PR author.
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:10>
* needs_better_patch: 0 => 1
* needs_docs: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:11>
* owner: Dulmandakh => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/23318#comment:12>