1
1
mirror of https://github.com/dbcli/pgcli.git synced 2024-10-04 01:08:51 +03:00
pgcli/tests
Rob Berry 97a1fd6c16
Allow defining a json file with preferred aliases (#1382)
* fix psycopg.sql.Identifier in \ev handling (#1384)

* Allow defining a json file with preferred aliases

At $WORK we have a lot of tables with names like `foo_noun_verb` or
`foo_noun_related-noun_verb` and so while the default aliasing is very
helpful for shortening unwieldy names we do end up with lots of aliases
like `LEFT JOIN fnv on fnv2.id = fnv.fnv2_id`

This change will allow defining a json file of preferred aliases

```
> cat ~/.config/pgcli/aliases.json
{
    "foo_user": "user",
    "foo_user_group": "user_group"
}
```

so the alias suggestion for `SELECT * FROM foo_user` will be `SELECT * FROM foo_user AS user`
instead of the default `SELECT * FROM foo_user AS fu`

* When cannot open or parse alias_map_file raise error

Raise a (hopefully) helpful exception when the alias_map_file cannot be
parsed or does not exist

* Add tests for load_alias_map_file

* Add tests for generate_alias

* Update AUTHORS file

* Remove comment.

Discussed this on the PR with a project maintainer

---------

Co-authored-by: Andy Schoenberger <akschoenberger@gmail.com>
Co-authored-by: Rob B <rob@example.com>
Co-authored-by: Irina Truong <i.chernyavska@gmail.com>
2023-10-06 16:13:28 -07:00
..
features Ask for confirmation to quit cli if a transaction is ongoing. (#1400) 2023-09-26 21:36:59 -07:00
formatter Fix sql-insert format emits NULL as 'None' (#1409) 2023-06-23 07:05:58 +02:00
parseutils Changed destructive_warning to take a list of destructive commands (#1328) 2022-10-13 14:42:22 -07:00
conftest.py Finer control over destructive warning. (#1242) 2021-02-12 21:09:38 -08:00
metadata.py Modernize code to Python 3.6+ (#1229) 2021-02-12 21:34:56 +02:00
pytest.ini Fix problem with travis not using correct python versions when testing. 2015-01-09 12:33:27 +02:00
test_auth.py Add test. 2022-06-10 11:26:53 -07:00
test_completion_refresher.py Another attempt to fix pgbouncer error (1093.) (#1097) 2021-05-21 15:32:34 -07:00
test_config.py skip initial comment in pg_session file (#1245) 2021-02-22 14:55:55 -08:00
test_fuzzy_completion.py removed py2-related stuff 2020-03-14 10:53:43 +08:00
test_main.py Added \echo & \qecho for Issue #1335 (#1371) 2023-10-06 15:56:48 -07:00
test_naive_completion.py Modernize code to Python 3.6+ (#1229) 2021-02-12 21:34:56 +02:00
test_pgcompleter.py Allow defining a json file with preferred aliases (#1382) 2023-10-06 16:13:28 -07:00
test_pgexecute.py fix psycopg.sql.Identifier in \ev handling (#1384) 2022-11-21 16:10:13 -08:00
test_pgspecial.py Modernize code to Python 3.6+ (#1229) 2021-02-12 21:34:56 +02:00
test_prioritization.py black all the things. (#1049) 2019-05-25 13:08:56 -07:00
test_prompt_utils.py Changed destructive_warning to take a list of destructive commands (#1328) 2022-10-13 14:42:22 -07:00
test_rowlimit.py Fix typos (#1345) 2022-06-08 11:38:29 -07:00
test_smart_completion_multiple_schemata.py Blacken. 2021-05-07 12:43:32 -07:00
test_smart_completion_public_schema_only.py Modernize code to Python 3.6+ (#1229) 2021-02-12 21:34:56 +02:00
test_sqlcompletion.py Fix typos (#1345) 2022-06-08 11:38:29 -07:00
test_ssh_tunnel.py ssh tunnels: allow configuring auto matches (#1302) 2022-02-21 10:20:11 -08:00
utils.py Port to psycopg3 (#1324) 2022-06-06 11:20:48 -07:00