diff options
author | Joakim Koljonen <koljonen@outlook.com> | 2017-07-05 20:13:08 +0200 |
---|---|---|
committer | Joakim Koljonen <koljonen@outlook.com> | 2017-07-07 17:22:17 +0200 |
commit | f5784746d9c5145663a8477476601c5098588ba3 (patch) | |
tree | 7dda76e65dcce46e0d775a1831c94fbb3d5c2ff1 /tests/metadata.py | |
parent | fdacd906a6395a0c81baa70b6fdb772d242a8621 (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/metadata.py')
-rw-r--r-- | tests/metadata.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/metadata.py b/tests/metadata.py index 18a07d56..ff395ea6 100644 --- a/tests/metadata.py +++ b/tests/metadata.py @@ -169,6 +169,12 @@ class MetaData(object): return completers + + def _make_col(self, sch, tbl, col): + defaults = self.metadata.get('defaults', {}).get(sch, {}) + return (sch, tbl, col, 'text', (tbl, col) in defaults, defaults.get((tbl, col))) + + def get_completer(self, settings=None, casing=None): metadata = self.metadata from pgcli.pgcompleter import PGCompleter @@ -182,13 +188,13 @@ class MetaData(object): for tbl, cols in tbls.items(): tables.append((sch, tbl)) # Let all columns be text columns - tbl_cols.extend([(sch, tbl, col, 'text', False, None) for col in cols]) + tbl_cols.extend([self._make_col(sch, tbl, col) for col in cols]) for sch, tbls in metadata.get('views', {}).items(): for tbl, cols in tbls.items(): views.append((sch, tbl)) # Let all columns be text columns - view_cols.extend([(sch, tbl, col, 'text', False, None) for col in cols]) + view_cols.extend([self._make_col(sch, tbl, col) for col in cols]) functions = [ FunctionMetadata(sch, *func_meta) |