public inbox for [email protected]  
help / color / mirror / Atom feed
From: Murtuza Zabuawala <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: PATCH: To support new version of sqlparse (pgAdmin4)
Date: Mon, 26 Sep 2016 17:14:53 +0530
Message-ID: <CAKKotZSWThWsD5J2S4EEN6n0Ya0S=u=HH2jhh-mHBJK7PM4PAA@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi,

PFA patch to address the issue where if user upgrades sqlparse module to
>0.1.19, it breaks sqleditor auto-complete feature.
RM#1725

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] RM_1725.patch (1.5K, 3-RM_1725.patch)
  download | inline diff:
diff --git a/web/pgadmin/utils/sqlautocomplete/autocomplete.py b/web/pgadmin/utils/sqlautocomplete/autocomplete.py
index fa6c56d..259c15e 100644
--- a/web/pgadmin/utils/sqlautocomplete/autocomplete.py
+++ b/web/pgadmin/utils/sqlautocomplete/autocomplete.py
@@ -671,6 +671,11 @@ class SQLAutoComplete(object):
                                                 full_text, identifier)
 
     def suggest_based_on_last_token(self, token, text_before_cursor, full_text, identifier):
+        # New version of sqlparse sends tuple, we need to make it
+        # compatible with our logic
+        if isinstance(token, tuple) and len(token) > 1:
+            token = token[1]
+
         if isinstance(token, string_types):
             token_v = token.lower()
         elif isinstance(token, Comparison):
diff --git a/web/pgadmin/utils/sqlautocomplete/parseutils.py b/web/pgadmin/utils/sqlautocomplete/parseutils.py
index 29020a9..8817711 100644
--- a/web/pgadmin/utils/sqlautocomplete/parseutils.py
+++ b/web/pgadmin/utils/sqlautocomplete/parseutils.py
@@ -275,7 +275,7 @@ def parse_partial_identifier(word):
     n_tok = len(p.tokens)
     if n_tok == 1 and isinstance(p.tokens[0], Identifier):
         return p.tokens[0]
-    elif p.token_next_match(0, Error, '"'):
+    elif hasattr(p, 'token_next_match') and p.token_next_match(0, Error, '"'):
         # An unmatched double quote, e.g. '"foo', 'foo."', or 'foo."bar'
         # Close the double quote, then reparse
         return parse_partial_identifier(word + '"')


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: PATCH: To support new version of sqlparse (pgAdmin4)
  In-Reply-To: <CAKKotZSWThWsD5J2S4EEN6n0Ya0S=u=HH2jhh-mHBJK7PM4PAA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox