Suggest columns for ORDER BY and DISTINCT (fixes #685) - #686
Conversation
22b5dce to
8bd2227
Compare
ORDER BY and DISTINCT (fix #685)ORDER BY and DISTINCT (fixes #685)
Codecov Report
@@ Coverage Diff @@
## master #686 +/- ##
=========================================
Coverage ? 79.05%
=========================================
Files ? 23
Lines ? 2535
Branches ? 0
=========================================
Hits ? 2004
Misses ? 531
Partials ? 0
Continue to review full report at Codecov.
|
|
Thanks for taking the time to make pgcli better. Sorry I haven't had time to look into this. I won't have time till end of this week, but if none of the other core devs have reviewed it by then, I'll take a look. Sorry about the delay. |
j-bennet
left a comment
There was a problem hiding this comment.
This looks good, and seems to work as expected - I tried it out on a few cases. I don't think that def table_reference is needed though.
|
|
||
| # Returns the expected select-clause suggestions for a single-table select | ||
|
|
||
| def table_reference(table, schema=None, alias=None, is_function=False): |
There was a problem hiding this comment.
TableReference instantiation is already a one-liner. What's the point of wrapping it into a function?
There was a problem hiding this comment.
On reflection, probably none, I think I added it before I did a bunch of line-wrapping. Of course, one can avoid passing a few parameters since table_reference has default parameters, but I don't think the method pulls its weight, I'll remove it.
| def test_distinct_suggests_cols(text): | ||
| suggestions = suggest_type(text, text) | ||
| assert suggestions ==(Column(table_refs=(), qualifiable=True),) | ||
| assert set(suggestions) == set([ |
There was a problem hiding this comment.
Wouldn't be a good PR without them...!
8bd2227 to
e5b5b8b
Compare
|
@owst Also, the line in changelog:
is not very clear. I would suggest something like:
|
|
Yeah, fair enough, I'm certainly not wedded to the current wording. The only thing is "fixed" to me suggests it was "broken" before, when I think it was just a missing feature. Perhaps
? |
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.
e5b5b8b to
3d560ba
Compare
|
@owst Yes, that is better! |
|
Looks good. Merging. Thank you! 🌷 |
Description
Having typed an alias name in an
ORDER BYor (SELECT)DISTINCTclause,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
SELECTandWHEREclauses.Checklist
changelog.md.AUTHORSfile (or it's already there).