summaryrefslogtreecommitdiffstats
path: root/tests/test_smart_completion_multiple_schemata.py
AgeCommit message (Collapse)Author
2021-05-07Blacken.Amjith Ramanujam
2021-05-07Add tests for search_path function completion.Amjith Ramanujam
2021-02-12Modernize code to Python 3.6+ (#1229)Miroslav Šedivý
1. `class A(object)` can be written as `class A:` 2. replace `dict([…])` and `set([…])` with `{…}` 3. use f-strings or compact `.format` 4. use `yield from` instead of `yield` in a `for` loop 5. import `mock` from `unittest` 6. expect `OSError` instead of `IOError` or `select` error 7. use Python3 defaults for file reading or `super()` 8. remove redundant parenthesis (keep those in tuples though) 9. shorten set intersection instead of creating lists 10. backslashes in strings do not have to be escaped if prepended with `r`
2020-03-14removed py2-related stuffGeorgy Frolov
2019-10-12fixup! Take account of table aliases when completing function args (#1048)Owen Stephens
2019-05-25black all the things. (#1049)Irina Truong
* added black to develop guide * no need for pep8radius. * changelog. * Add pre-commit checkbox. * Add pre-commit to dev reqs. * Add pyproject.toml for black. * Pre-commit config. * Add black to travis and dev reqs. * Install and run black in travis. * Remove black from dev reqs. * Lower black target version. * Re-format with black.
2019-02-08fix unhashable formatted textDick Marinus
2019-01-02Remove some functions completions (#982)Irina Truong
Remove extension and private functions from completer.
2018-09-22Revert abs imports in tests.Irina Truong
2018-09-22Attempt to fix failing tests. Add some debug info. Make imports py3-compatible.Irina Truong
2017-08-06Don't quote identifiers that coïncide with non-reserved keywordsJoakim Koljonen
Keep track of which keywords are reserved, and quote identifiers that coïncide with those. https://www.postgresql.org/docs/10/static/sql-keywords-appendix.html
2017-07-16Merge branch 'master' into koljonen/suggest_functions_with_argsJoakim Koljonen
2017-07-07Skip unwanted columns when expanding `INSERT INTO tbl(*`Joakim Koljonen
Skip those that have a default value of some sequence (i.e. serial columns) and those that have a default value of 'now()'.
2017-06-25Include arguments in function completionsJoakim Koljonen
E.g. instead of suggesting `my_func()`, suggest `my_func(arg1 :=, arg2 :=)` or `my_func(arg1 text, arg2 bigint)`, depending on the context.
2017-06-14Fix PEP8 empty line errorsÉtienne BERSAC
2017-06-09Schema name should be escaped in SET SCHEMA.Irina Truong
2017-03-17Make pylint happier with metadata.pyJoakim Koljonen
A bunch of cosmetic changes to be more compliant with PEP80 and pylint. And I added a pylintrc so that we can ignore some rules that just add too much clutter.
2017-03-15Deduplicate tests: Add some helper functions to metadata.pyJoakim Koljonen
2017-03-15Deduplicate tests: Various simplificationsJoakim Koljonen
Remove unnecessary variables, unnecessary calls to set().
2017-03-15Deduplicate tests: add metadata.qual, metadata.no_qualJoakim Koljonen
Put some commonly used settings for the completer parametrization in metadata.py to avoid repeating them for a bunch of tests.
2017-03-15Deduplicate tests: Add Testdata.get_result() methodJoakim Koljonen
Basically put some code that was in every smart_completion test in this method.
2017-03-15Deduplicate tests: Change len('...') to len(text)Joakim Koljonen
This is to simplify the next commit.
2017-03-15Add empty lines between functions (PEP 80)Joakim Koljonen
2017-03-15Parametrize completer in testsJoakim Koljonen
This introduces functionality for running the same test case for different completer settings. This should improve code-path coverage. I've set up all the old tests to run with all configs that should have identical output.
2017-03-14Merge pull request #649 from dbcli/koljonen/suggest_from_all_schemasdarikg
Suggest objects from schemas not in search_path
2017-03-13Make schema-qualified objects sort after non-schema-qualifiedJoakim Koljonen
2017-03-09Find statements inside function bodykoljonen
Consider this script ``` CREATE FUNCTION foo() returns text LANGUAGE SQL AS $func$ SELECT 1 FROM Bar; SELECT <cursor> FROM Baz; $func$; ``` The change here is that `SELECT <cursor> FROM Baz;` will be seen as the current statement, instead of the whole function definition. This means we'll no longer get column suggestions from `Bar`.
2017-03-05Start suggesting tables/functions/views/types not in search_pathJoakim Koljonen
And schema-qualifying them, of course, so that for `SELECT * FROM bar` we might suggest `buildings.barns` and for `select dopi` we might suggest `maintenance.delete_old_personal_info()`, for example. Controlled by a config setting, `search_path_filter`, in case anyone prefers the old behaviour.
2016-12-12Initialism search for columns and functionsJoakim Koljonen
E.g. for table `Foo` with columns `FooBar` and `Fabulous`, inputting `SELECT * FROM Foo F WHERE F.fb` will suggest `FooBar` as the #1 choice. Likewise, given the functions `baz_baz()` and `baab()`, inputting `SELECT bb` will have `baz_baz()` as the first option.
2016-12-12Search table suggestions using initialismsJoakim Koljonen
The idea is that if you have e.g. a table called `FooBar`, where we'd use the initialism `FB` as an alias (suggesting `FooBar FB`), inputting e.g. `SELECT * FROM FB` should suggest `FooBar FB` (or `FooBar` if aliasing is disabled). Ditto for functions, views and joins. The solution is that we send `FB` as a `synonym` to `find_matches`, which results in the `FooBar` suggestion rising to the top (above e.g. `FabulousTable`).
2016-11-20Fix scoping for columns from CTEsJoakim Koljonen
We were suggesting all CTE columns regardless of whether the CTE in question was included in the FROM clause.
2016-07-06Better scoping for tables in insert statementskoljonen
This commit makes it so that given `INSERT INTO foo(<cursor1>) SELECT <cursor2> FROM bar;`, we suggest `bar` columns for `<cursor2>` and `foo` columns for `<cursor1>`. Previous behaviour is sugggesting columns from both tables in both cases.
2016-06-27Suggest table aliases + add tests for casingkoljonen
If config.main.generate_aliases is True, for `SELECT * FROM `, we suggest `FooBar FB` and `foo_bar fb` instead of `FooBar` and `foo_bar`, respectively. To be able to add a test, I had to add support for testing with different settings, which meant I could also add tests for casing. There are two non-obvious changes that I can think of: 1. The lexical sorting of matches is modified so as to sort spaces and underscores before letters and to sort case-insensitively. This is so that e.g `Foob F` comes before 'FooBar FB' when `foob` is input. 2. We now suggest `some_func()` instead of `some_func` (because suggesting `some_func sf` didn't make any sense).
2016-06-18Fix indentation of test_smart_completion_* metadata dictskoljonen
2016-06-18In completion tests, get columns from metadata instead of manually listing themkoljonen
2016-06-18In completion tests, get functions from metadata instead of manually listing ↵koljonen
them
2016-06-18In completion tests, get tables from metadata instead of manually listing themkoljonen
2016-06-18In completion tests, get datatypes from metadata instead of manually listing ↵koljonen
them
2016-06-18In completion tests, get schemas from metadata instead of manually listing themkoljonen
2016-06-18Consolidate common code in smart_completion testskoljonen
2016-06-16Fix some join-condition issueskoljonen
When self-joining a table with an FK to or from some other table, we got a false FK-join suggestion for that column. There was also a problem with quoted tables not being quoted in the join condition. And there were a couple of problems when trying to join a non-existent table or using a non-existent qualifier (`SELECT * FROM Foo JOIN Bar ON Meow.`). I also rewrote get_join_condition_matches a bit in the process, hopefully making it a bit simpler.
2016-06-14Join conditions: alias tables already included in querykoljonen
If we have the input `SELECT * FROM Foo JOIN `, we now suggest `Foo Foo2 ON Foo2.ParentID = Foo.ID` (given the appropriate casing file and FK). There were also some problems with quoted tables and with the casing of table aliases, which are now fixed. I also made a few cosmetic changes to get_join_matches (pgcompleter.py) just to make it a bit easier to work with.
2016-06-10Various changes after reviewkoljonen
2016-06-02Use pg_proc.proargmodes &c. instead of parsing arg_listkoljonen
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.
2016-05-27Fix two casing issues with schemaskoljonen
1. In 'SELECT * FROM Foo.', Foo was not recognized as foo. 2. In 'SELECT * FROM "Foo"', objects in Foo were not suggested.
2016-05-25Merge pull request #510 from koljonen/fixtablecasingissue2darikg
Fix another problem where table names would not be recognized when nott in lower case
2016-05-25Fix another problem where table names would not be recognized when not in ↵koljonen
lower case My previous fix didn't cover the case 'INSERT INTO Foo(<cursor>)', which is now covered.
2016-05-24Support for join-condition suggestions after ONkoljonen
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.
2016-05-20Fix problem where table names would not be recognized when not in lower casekoljonen
2016-05-17Stop suggesting * as a columnkoljonen
I don't think suggesting * is of use to anyone, and it's in the way for anyone who just wants a column.