Getting the parameters from proargnames, proallargtypes and proargmodes instead of from parsing the arg_list string simplifies FunctionMetadata quite a bit.
I also made the ColumnMetadata for table/view columns use the same format for the type (i.e. regtype instead of typname). This means we now get join-condition suggestions for joining tables/views to functions, which didn't work before.
The user types 'SELECT * FROM parenttable p JOIN childtable c on '. We then suggest ['c.parenttableid = p.parenttableid', 'c.createdby = p.createdby', ...] as completions.
The suggestions are FK matches first, then name matches for int columns, then name matches for other columns, sorted by proximity from the cursor to the other table.
Some changes:
For "JOIN Foo USING(<cursor>)", now only columns present in Foo are suggested.
For all suggestions after 'ON', now only the tables before the cursor are considered.
meta[reltype]][relname] goes from being a list of columns to being an OrderedDict {column_name:ColumnMetadata}, where the ColumnMetaData contains the column's name, data type and a list of FKs involving the column. This entails modification of a number of functions dealing with columns.
This also allows us to simplify some of the tests in test_pgexecute,
which tested with and without expanded output by first running '\x',
which is a pretty roundabout way of mutating a global variable
generalize tables() to _relations(relkind_filter), and add convenience methods tables() and views() which simply call _relations() with the appropriate relkind_filter value
similarly, generatize columns() to _columns(relkind_filter), and add convenience methods table_columns() and view_columns()
Note that if any of the queries raises an error, nothing besides the error is
output. This is different behavior from psql which outputs separately for each
query:
_test_db=# select 1; invalid syntax; select 2;
?column?
----------
1
(1 row)
ERROR: syntax error at or near "invalid"
LINE 1: invalid syntax;
^
?column?
----------
2
(1 row)