public inbox for [email protected]  
help / color / mirror / Atom feed
PATCH: To support new version of sqlparse (pgAdmin4)
2+ messages / 2 participants
[nested] [flat]

* PATCH: To support new version of sqlparse (pgAdmin4)
@ 2016-09-26 11:44 Murtuza Zabuawala <[email protected]>
  2016-09-26 12:50 ` Re: PATCH: To support new version of sqlparse (pgAdmin4) Dave Page <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Murtuza Zabuawala @ 2016-09-26 11:44 UTC (permalink / raw)
  To: pgadmin-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 + '"')


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: PATCH: To support new version of sqlparse (pgAdmin4)
  2016-09-26 11:44 PATCH: To support new version of sqlparse (pgAdmin4) Murtuza Zabuawala <[email protected]>
@ 2016-09-26 12:50 ` Dave Page <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Page @ 2016-09-26 12:50 UTC (permalink / raw)
  To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers

Thanks - applied!

On Mon, Sep 26, 2016 at 12:44 PM, Murtuza Zabuawala
<[email protected]> wrote:
> 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
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: 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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2016-09-26 12:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-26 11:44 PATCH: To support new version of sqlparse (pgAdmin4) Murtuza Zabuawala <[email protected]>
2016-09-26 12:50 ` Dave Page <[email protected]>

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