From b92743368bfc357f72a4046e899faef899ee9972 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Wed, 31 Oct 2018 18:42:27 +0100 Subject: Bugfix for #938: load named queries from provided config file --- AUTHORS | 2 +- changelog.rst | 5 +++-- pgcli/main.py | 7 ++++++- pgcli/pgcompleter.py | 3 --- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index 9e78537e..50779ce4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -85,7 +85,7 @@ Contributors: * Artur Balabanov * Kenny Do * Max Rothman - * DanEEStar + * Daniel Egger Creator: -------- diff --git a/changelog.rst b/changelog.rst index 650599e1..2a7505dc 100644 --- a/changelog.rst +++ b/changelog.rst @@ -4,7 +4,8 @@ Upcoming: Bug fixes: ---------- -Set default port in `connect_uri` when none is given. (Thanks: `DanEEStar`_) +* Fix for loading/saving named queries from provided config file (#938). (Thanks: `Daniel Egger`_) +* Set default port in `connect_uri` when none is given. (Thanks: `Daniel Egger`_) * Fix for error listing databases (#951). (Thanks: `Irina Truong`_) Internal: @@ -897,4 +898,4 @@ Improvements: .. _`Artur Balabanov`: https://github.com/arturbalabanov .. _`Kenny Do`: https://github.com/kennydo .. _`Max Rothman`: https://github.com/maxrothman -.. _`DanEEStar`: https://github.com/DanEEStar +.. _`Daniel Egger`: https://github.com/DanEEStar diff --git a/pgcli/main.py b/pgcli/main.py index ce3e88aa..446470e3 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -1,7 +1,10 @@ -from __future__ import unicode_literals from __future__ import print_function +from __future__ import unicode_literals import warnings + +from pgspecial.namedqueries import NamedQueries + warnings.filterwarnings("ignore", category=UserWarning, module='psycopg2') import os @@ -146,6 +149,8 @@ class PGCli(object): # Load config. c = self.config = get_config(pgclirc_file) + NamedQueries.instance = NamedQueries.from_config(self.config) + self.logger = logging.getLogger(__name__) self.initialize_logging() diff --git a/pgcli/pgcompleter.py b/pgcli/pgcompleter.py index 7eaadc86..2ec0ac5a 100644 --- a/pgcli/pgcompleter.py +++ b/pgcli/pgcompleter.py @@ -21,9 +21,6 @@ from .config import load_config, config_location _logger = logging.getLogger(__name__) -NamedQueries.instance = NamedQueries.from_config( - load_config(config_location() + 'config')) - Match = namedtuple('Match', ['completion', 'priority']) _SchemaObject = namedtuple('SchemaObject', 'name schema meta') -- cgit v1.2.3