summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2016-10-26 12:36:31 -0700
committerGitHub <noreply@github.com>2016-10-26 12:36:31 -0700
commita2f1f6352352a8993b391df10a8740ab3c366585 (patch)
tree111223c324d8cc0d2c51d83600d7620c35939e19
parent964b89ebc4c8312a7b176af710e08a3b46a2720a (diff)
parentdd43364feb558288623f27d10b0603d745dfa491 (diff)
Merge pull request #606 from dbcli/darikg/sqlparse022
Bump sqlparse to 0.2.2
-rw-r--r--pgcli/packages/parseutils/tables.py2
-rw-r--r--pgcli/packages/parseutils/utils.py26
-rw-r--r--pgcli/packages/sqlcompletion.py4
-rw-r--r--setup.py2
4 files changed, 7 insertions, 27 deletions
diff --git a/pgcli/packages/parseutils/tables.py b/pgcli/packages/parseutils/tables.py
index 72cdcc6b..12513591 100644
--- a/pgcli/packages/parseutils/tables.py
+++ b/pgcli/packages/parseutils/tables.py
@@ -14,7 +14,7 @@ TableReference.ref = property(lambda self: self.alias or (
# This code is borrowed from sqlparse example script.
# <url>
def is_subselect(parsed):
- if not parsed.is_group():
+ if not parsed.is_group:
return False
for item in parsed.tokens:
if item.ttype is DML and item.value.upper() in ('SELECT', 'INSERT',
diff --git a/pgcli/packages/parseutils/utils.py b/pgcli/packages/parseutils/utils.py
index 4dee1fc7..4584c0f5 100644
--- a/pgcli/packages/parseutils/utils.py
+++ b/pgcli/packages/parseutils/utils.py
@@ -112,30 +112,8 @@ def is_open_quote(sql):
def _parsed_is_open_quote(parsed):
- tokens = list(parsed.flatten())
-
- i = 0
- while i < len(tokens):
- tok = tokens[i]
- if tok.match(Token.Error, "'"):
- # An unmatched single quote
- return True
- elif (tok.ttype in Token.Name.Builtin
- and dollar_quote_regex.match(tok.value)):
- # Find the matching closing dollar quote sign
- for (j, tok2) in enumerate(tokens[i+1:], i+1):
- if tok2.match(Token.Name.Builtin, tok.value):
- # Found the matching closing quote - continue our scan for
- # open quotes thereafter
- i = j
- break
- else:
- # No matching dollar sign quote
- return True
-
- i += 1
-
- return False
+ # Look for unmatched single quotes, or unmatched dollar sign quotes
+ return any(tok.match(Token.Error, ("'", "$")) for tok in parsed.flatten())
def parse_partial_identifier(word):
diff --git a/pgcli/packages/sqlcompletion.py b/pgcli/packages/sqlcompletion.py
index b1a59da9..1e537a22 100644
--- a/pgcli/packages/sqlcompletion.py
+++ b/pgcli/packages/sqlcompletion.py
@@ -358,7 +358,9 @@ def suggest_based_on_last_token(token, stmt):
return (Column(table_refs=tables, local_tables=stmt.local_tables),
Function(schema=None),
Keyword(),)
-
+ elif token_v == 'as':
+ # Don't suggest anything for aliases
+ return ()
elif (token_v.endswith('join') and token.is_keyword) or (token_v in
('copy', 'from', 'update', 'into', 'describe', 'truncate')):
diff --git a/setup.py b/setup.py
index 062941a9..3d0c1a44 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@ install_requirements = [
'Pygments >= 2.0', # Pygments has to be Capitalcased. WTF?
'prompt_toolkit>=1.0.0,<1.1.0',
'psycopg2 >= 2.5.4',
- 'sqlparse >=0.2.0,<0.3.0',
+ 'sqlparse >=0.2.2,<0.3.0',
'configobj >= 5.0.6',
'humanize >= 0.5.1',
'wcwidth >= 0.1.6',