1
1
mirror of https://github.com/dbcli/pgcli.git synced 2024-10-06 10:17:15 +03:00
Commit Graph

314 Commits

Author SHA1 Message Date
Dick Marinus
8fa3d18353 behave test source command 2017-04-28 21:16:11 +02:00
Dick Marinus
6f1f4bfa8e behave quit pgcli nicely 2017-04-28 18:00:51 +02:00
Irina Truong
bad238f996 Merge pull request #686 from owst/column_completion_for_order_by_and_distinct
Suggest columns for `ORDER BY` and `DISTINCT` (fixes #685)
2017-04-26 11:01:32 -07:00
Owen Stephens
3d560baf6c Suggest columns for ORDER BY and DISTINCT (fixes #685)
Having typed an alias name in an `ORDER BY` or (`SELECT`) `DISTINCT`
clause, the alias was not taken account of, and the completion simply
listed all columns. This change fixes that, and makes the autocompletion
behave the same as in `SELECT` and `WHERE` clauses.
2017-04-26 01:10:57 +01:00
Dick Marinus
bc47a07d92 behave pager wrapper 2017-04-25 07:37:53 +02:00
Amjith Ramanujam
1e1d980ae2 Merge pull request #667 from dbcli/koljonen/tests_parametrize_completer
Parametrize completer in tests + deduplicate test code
2017-04-21 07:40:13 -07:00
Amjith Ramanujam
edf40d052b Merge branch 'master' into koljonen/case_column_titles 2017-04-21 07:38:14 -07:00
Irina Truong
578a36a6c0 Switched back to expect_exact in iocommands test. 2017-03-31 16:08:59 -07:00
Dick Marinus
586738f0b3 switch from nano to ex 2017-03-31 16:04:18 -07:00
Dick Marinus
aaf31e87be Fix coverage tests, fix PGPASSWORD
- I've copied my changes in .travis.yml from mycli
- Changed PGPASS to PGPASSWORD
2017-03-31 16:00:54 -07:00
Irina Truong
38558e165e After editor command, expect colored sql. 2017-03-31 16:00:54 -07:00
Irina Truong
19511b0fe9 Renamed pgcli to dbcli and postgres to dbserver, to make .feature files reusable. 2017-03-31 16:00:54 -07:00
Irina Truong
4aea9015aa Added coverage support for functional tests. 2017-03-31 16:00:54 -07:00
Irina Truong
5fdcb889bd Fixed failing test. 2017-03-31 16:00:54 -07:00
Irina Truong
8b1b486871 Housekeeping: separated test steps into different files. 2017-03-31 16:00:54 -07:00
Irina Truong
fcff05d4db Removed unnecessary 'pgcli installed' test step. 2017-03-31 16:00:54 -07:00
Joakim Koljonen
76b6098afd
Make pylint happier with metadata.py
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-17 03:33:41 +01:00
Joakim Koljonen
9a8d2c2d6f
Make format_output take a settings object 2017-03-16 03:06:56 +01:00
Joakim Koljonen
6188c86201
Deduplicate tests: Add some helper functions to metadata.py 2017-03-15 02:58:02 +01:00
Joakim Koljonen
17ff3bb937
Deduplicate tests: Various simplifications
Remove unnecessary variables, unnecessary calls to set().
2017-03-15 02:57:32 +01:00
Joakim Koljonen
d67329279f
Deduplicate tests: add metadata.qual, metadata.no_qual
Put some commonly used settings for the completer parametrization
in metadata.py to avoid repeating them for a bunch of tests.
2017-03-15 02:57:18 +01:00
Joakim Koljonen
83a1661ed3
Deduplicate tests: Add Testdata.get_result() method
Basically put some code that was in every smart_completion test in
this method.
2017-03-15 02:56:58 +01:00
Joakim Koljonen
8c487c7d78
Deduplicate tests: Change len('...') to len(text)
This is to simplify the next commit.
2017-03-15 02:56:29 +01:00
Joakim Koljonen
3f51a6e596
Add empty lines between functions (PEP 80) 2017-03-15 02:55:40 +01:00
Joakim Koljonen
c0a1220444
Parametrize completer in tests
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-15 02:55:28 +01:00
darikg
7b14da9b4c Merge pull request #649 from dbcli/koljonen/suggest_from_all_schemas
Suggest objects from schemas not in search_path
2017-03-14 16:36:36 -04:00
Joakim Koljonen
cec8aaf16d
Make schema-qualified objects sort after non-schema-qualified 2017-03-13 22:58:31 +01:00
koljonen
1277752d62
Find statements inside function body
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-09 01:41:11 +01:00
Amjith Ramanujam
7f009c630f Add support for unicode chars in expanded mode. 2017-03-06 19:20:34 -08:00
Joakim Koljonen
6b8c62d0ec
Add MATERIALIZED VIEW keywords 2017-03-06 23:16:29 +01:00
Joakim Koljonen
bdf2a0e26a
Start suggesting tables/functions/views/types not in search_path
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.
2017-03-05 02:21:31 +01:00
Darik Gamble
f314f8301b Suggest keywords after ALTER 2017-02-25 09:01:11 -05:00
Joakim Koljonen
ce55abc660
Initialism search for columns and functions
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-12 02:45:39 +01:00
Joakim Koljonen
813afcaf11
Search table suggestions using initialisms
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-12-12 02:45:39 +01:00
koljonen
45326335e6
Support for table-qualifying column suggestions
... i.e. suggesting foo.fooid instead of just fooid
Controlled using a config-file setting:
**qualify_columns**: always/never/**if_more_than_one_table**.

To enable the proper sorting of qualified column suggestions, we
introduce the concept of synonyms for suggestions
(in `pgcompleter.find_matches`). They way synonyms work is that a
number of synonyms may be provided for a suggestion sent to
`find_matches`. If synonyms are provided, sorting is based on how
well the best synonym matches the input, instead of only comparing
the input to the suggestion text.
In this case, the unqualified name acts as a synonym.
I have a couple of other ideas of use cases where we can use synonyms
to get better completions with less typing for the user, which I intend
to explore later.
2016-12-05 03:15:53 +01:00
Joakim Koljonen
c2e76e335e
Fix scoping for columns from CTEs
We were suggesting all CTE columns regardless of whether the CTE in
question was included in the FROM clause.
2016-11-20 23:01:41 +01:00
Joakim Koljonen
279d6e85a7
Fix crash after with 2016-11-20 21:18:40 +01:00
Lele Gaifax
d923ab3efd Fix issue #603
Python 3 forbids comparisons between different types: use a tuple
containing a single 0 (zero) as the priority for path matches so that it
can be compared with those generated by the workhorse method find_matches().
2016-10-31 18:33:07 +01:00
Darik Gamble
0881902207 If prev_keyword is an unrecognized keyword, go backward until we find a recognized one 2016-10-17 13:48:55 -04:00
Foxygrandpa
0ef94c984b master: decimal and float format in config file 2016-09-27 13:43:28 +03:00
Foxygrandpa
fa4ebb5660 master: numbers division for int and float 2016-09-15 20:55:42 +03:00
Joakim Koljonen
514b594909
Fix crash bug with leading parenthesis 2016-09-12 23:48:22 +02:00
Darik Gamble
f506dfbcaa Support configuring keyword casing preferences 2016-09-04 08:41:15 -04:00
Amjith Ramanujam
db496fb354 Merge pull request #568 from dbcli/koljonen/hack_for_sqlparse_crashes
Temporary hack for sqlparse crashing after AS
2016-08-23 17:23:46 -07:00
Joakim Koljonen
8d2265a65d
Temporary hack for sqlparse crashing after AS
And a regression test.
2016-08-23 20:14:00 +02:00
Joakim Koljonen
6d41a8a6bd
Fix crash bug with named queries
And add behave tests.
2016-08-23 13:47:04 +02:00
Amjith Ramanujam
ab6e54b2cf Merge pull request #553 from dbcli/darikg/cte-suggestions
CTE-aware suggestions
2016-08-08 22:10:29 -07:00
Amjith Ramanujam
fb23a1e4ec Merge pull request #554 from dbcli/koljonen/suggestion_sorting
Some changes to sorting of suggestions
2016-07-29 07:33:37 -07:00
Darik Gamble
2407de0e4c Make suggestions based on local tables 2016-07-27 15:33:59 -04:00
Darik Gamble
8b8f257100 Rename the suggestion field tables to table_refs so we can add more table-specific properties without getting confused 2016-07-27 15:33:58 -04:00