Opened 22 months ago

Last modified 14 months ago

#23318 assigned New feature

Management command dbshell does not use DATABASE[...]['OPTIONS'] to set env PGOPTIONS

Reported by: benjaoming Owned by: fcurella
Component: Core (Management commands) Version: master
Severity: Normal Keywords:
Cc: tomi.kyostila@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


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 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 sqlall south | python dbshell --database=DBNAME

Current work-around:

python sqlall south | PGOPTIONS="-c search_path=NAME_OF_MY_SCHEMA" python 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.

Change History (5)

comment:1 Changed 21 months ago by timgraham

  • Component changed from Database layer (models, ORM) to Core (Management commands)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Bug to New feature

It looks like a reasonable request, and we recently enhanced the options that dbshell accepts when using MySQL (#22646).

comment:2 Changed 21 months ago by fcurella

  • Owner changed from nobody to fcurella
  • Status changed from new to assigned

comment:3 Changed 21 months ago by fcurella

  • Easy pickings set
  • Has patch set
  • Version changed from 1.7-rc-2 to master

comment:4 Changed 21 months ago by timgraham

  • Easy pickings unset
  • Patch needs improvement set

I left comments for improvement on the PR. Please uncheck "Patch needs improvement" when you update it, thanks.

comment:5 Changed 14 months ago by tomikyos

  • Cc tomi.kyostila@… added
Note: See TracTickets for help on using tickets.
Back to Top