- Notifications
You must be signed in to change notification settings - Fork 578
Description
Description
First of all, thanks for a great tool, I use it a lot.
User comments to the pgcli config file are getting lost after the config file gets modified via pgcli itself (e.g. adding a named query). According to #1162 (comment) they should remain. Additionally, all whitelines from at least the [named queries] section onward get lost as well.
I can reproduce this on a clean virtualenv and with a fresh config file.
Reproduce
Log from my reproduction attempts:
- Removed previous config file
- Created new temp virtualenv (using the system Python 3.6.9), installed new pgcli (
pip install pgcli) - Started
pgcli, this created a new config file - Config file (from
[named queries]section onward; same goes for the config file snippets below) at this point:# Named queries are queries you can execute by name. [named queries] # DSN to call by -D option [alias_dsn] # example_dsn = postgresql://[user[:password]@][netloc][:port][/dbname] # Format for number representation # for decimal "d" - 12345678, ",d" - 12,345,678 # for float "g" - 123456.78, ",g" - 123,456.78 [data_formats] decimal = "" float = "" - Save new named query from
pgcli:\ns foo bar. Config file snippet after this:[named queries] foo = bar [alias_dsn] [data_formats] decimal = "" float = ""
- NOTE: the "# Named queries are queries you can execute by name." comment (and the preceding whiteline) above the
[named query]section header is now gone as well (while the "# style classes for colored table output" comment aboveoutput.header = "#00ff5f bold"remained in tact. As did all other comment and whitelines earlier in the file)
- NOTE: the "# Named queries are queries you can execute by name." comment (and the preceding whiteline) above the
- Close
pgcli(just in case), add user comment above thefoo = barnamed query entry. Config file snippet after this:[named queries] # My comment foo = bar [alias_dsn] [data_formats] decimal = "" float = ""
- Start
pgcliagain, add new named query:\ns bar SELECT 1. Config file snippet after this:[named queries] foo = bar bar = SELECT 1 [alias_dsn] [data_formats] decimal = "" float = ""
- Close
pgcli(just in case), add record and comment to[alias_dsn]. Config file snippet after this:[named queries] foo = bar bar = SELECT 1 [alias_dsn] # I feel like I'm getting lost baz = postgresql://foo@localhost/postgres [data_formats] decimal = "" float = ""
- Start
pgcliagain, add new named query:\ns baz SELECT 2. Config file snippet after this:[named queries] foo = bar bar = SELECT 1 baz = SELECT 2 [alias_dsn] baz = postgresql://foo@localhost/postgres [data_formats] decimal = "" float = ""
Did another quick test (only some of the steps from above) with a Python 3.9.0 (via pyenv) temp virtualenv, same results. Tried this one with both a pip install pgcli and a pip install git+https://github.com/dbcli/pgcli@master.
The same happens in my proper config file using my proper pgcli install, which contains many more named queries and DSN aliases.
Environment, verison info
-
OS: Ubuntu 18.04.5 (x64)
-
pgcli:
- In most of the tests above:
Server: PostgreSQL 9.6.13 Version: 3.1.0 - My proper install:
Version: 3.0.0
- In most of the tests above:
-
pip freezeof my proper install: