summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarik Gamble <darik.gamble@gmail.com>2015-02-27 10:04:59 -0500
committerDarik Gamble <darik.gamble@gmail.com>2015-02-27 10:04:59 -0500
commit5d44904aa3f7d25c0eba2ae2893d966fa64a0598 (patch)
treeb16231856c70d608a41afecf8867de33dab2da4a
parent5189ace117b8c3fcf6e8bb97e7507fe79cfa4806 (diff)
\df suggests only schemas and functions
-rw-r--r--pgcli/packages/sqlcompletion.py5
-rw-r--r--tests/test_pgspecial.py7
2 files changed, 12 insertions, 0 deletions
diff --git a/pgcli/packages/sqlcompletion.py b/pgcli/packages/sqlcompletion.py
index 5185c8be..91bd616d 100644
--- a/pgcli/packages/sqlcompletion.py
+++ b/pgcli/packages/sqlcompletion.py
@@ -103,6 +103,11 @@ def suggest_special(text):
return [{'type': 'table', 'schema': schema}]
else:
return [{'type': 'schema'}, {'type': 'table', 'schema': []}]
+ elif cmd[1:] == 'df':
+ if schema:
+ return [{'type': 'function', 'schema': schema}]
+ else:
+ return [{'type': 'schema'}, {'type': 'function', 'schema': []}]
return [{'type': 'keyword'}, {'type': 'special'}]
diff --git a/tests/test_pgspecial.py b/tests/test_pgspecial.py
index 9d2834bc..e16631a2 100644
--- a/tests/test_pgspecial.py
+++ b/tests/test_pgspecial.py
@@ -27,3 +27,10 @@ def test_d_dot_suggests_schema_qualified_tables():
suggestions = suggest_type('\d myschema.xxx', '\d myschema.xxx')
assert suggestions == [{'type': 'table', 'schema': 'myschema'}]
+def test_df_suggests_schema_or_function():
+ suggestions = suggest_type('\\df xxx', '\\df xxx')
+ assert sorted_dicts(suggestions) == sorted_dicts([
+ {'type': 'function', 'schema': []}, {'type': 'schema'}])
+
+ suggestions = suggest_type('\\df myschema.xxx', '\\df myschema.xxx')
+ assert suggestions == [{'type': 'function', 'schema': 'myschema'}]