summaryrefslogtreecommitdiffstats
path: root/tests/test_smart_completion_multiple_schemata.py
diff options
context:
space:
mode:
authorJoakim Koljonen <koljonen@outlook.com>2017-07-05 20:13:08 +0200
committerJoakim Koljonen <koljonen@outlook.com>2017-07-07 17:22:17 +0200
commitf5784746d9c5145663a8477476601c5098588ba3 (patch)
tree7dda76e65dcce46e0d775a1831c94fbb3d5c2ff1 /tests/test_smart_completion_multiple_schemata.py
parentfdacd906a6395a0c81baa70b6fdb772d242a8621 (diff)
Skip unwanted columns when expanding `INSERT INTO tbl(*`
Skip those that have a default value of some sequence (i.e. serial columns) and those that have a default value of 'now()'.
Diffstat (limited to 'tests/test_smart_completion_multiple_schemata.py')
-rw-r--r--tests/test_smart_completion_multiple_schemata.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/test_smart_completion_multiple_schemata.py b/tests/test_smart_completion_multiple_schemata.py
index 89e2f568..03d0ec88 100644
--- a/tests/test_smart_completion_multiple_schemata.py
+++ b/tests/test_smart_completion_multiple_schemata.py
@@ -8,7 +8,7 @@ metadata = {
'tables': {
'public': {
'users': ['id', 'email', 'first_name', 'last_name'],
- 'orders': ['id', 'ordered_date', 'status'],
+ 'orders': ['id', 'ordered_date', 'status', 'datestamp'],
'select': ['id', 'insert', 'ABC']
},
'custom': {
@@ -58,6 +58,13 @@ metadata = {
('blog', 'tags', 'tagid', 'blog', 'entrytags', 'tagid'),
],
},
+ 'defaults': {
+ 'public': {
+ ('orders', 'id'): "nextval('orders_id_seq'::regclass)",
+ ('orders', 'datestamp'): "now()",
+ ('orders', 'status'): "'PENDING'::text",
+ }
+ },
}
testdata = MetaData(metadata)
@@ -135,6 +142,17 @@ def test_suggested_column_names_from_schema_qualifed_table(completer):
))
+@parametrize('text', [
+ 'INSERT INTO orders(',
+ 'INSERT INTO orders (',
+ 'INSERT INTO public.orders(',
+ 'INSERT INTO public.orders ('
+])
+@parametrize('completer', completers(filtr=True, casing=False))
+def test_suggested_columns_with_insert(completer, text):
+ assert result_set(completer, text) == set(testdata.columns('orders'))
+
+
@parametrize('completer', completers(filtr=True, casing=False, qualify=no_qual))
def test_suggested_column_names_in_function(completer):
result = result_set(
@@ -335,7 +353,7 @@ def test_wildcard_column_expansion_with_insert(completer, text):
position = text.index('*') + 1
completions = get_result(completer, text, position)
- expected = [wildcard_expansion('id, ordered_date, status')]
+ expected = [wildcard_expansion('ordered_date, status')]
assert expected == completions