microsoft / azuredatastudio

Azure Data Studio is a data management and development tool with connectivity to popular cloud and on-premises databases. Azure Data Studio supports Windows, macOS, and Linux, with immediate capability to connect to Azure SQL and SQL Server. Browse the extension library for more database support options including MySQL, PostgreSQL, and MongoDB.
https://learn.microsoft.com/sql/azure-data-studio
MIT License
7.58k stars 906 forks source link

Autocomplete broken for table aliases #2552

Open justingrant opened 6 years ago

justingrant commented 6 years ago

Issue Type: Bug

When I try to enter a table alias, autocomplete changes my alias name to random matching keywords unless I manually cancel autocomplete. This is frustrating.

Repro:

  1. New query
  2. select * (press enter to go to next line)
  3. from Machine
  4. type a space and then the three characters mac (without quotes) and hit Enter to go to the next line

Expected: No autocomplete, because this is a table alias. Or if I do see autocomplete, I don't expect it to complete a keyword that doesn't even match what I typed.

Actual: It autocompletes to the closest matching keyword which is NAMESPACE (!!) which doesn't even contain what I typed. If I use "as" to preface the alias, then I get a different autocomplete problem where it matches the table "Machine" instead of allowing me to add my alias.

Autocomplete should realize that the context I'm typing in is an alias so should turn off autocomplete in this context. Or at the very least, autocomplete should be smarter about matching only contiguous "contains" matches. Even better, autocomplete should be smarter about "contains" matching for keywords. For identifiers, e.g. "SalesAndProfitTable" I guess it makes sense to match when I type "Profit". But for keywords that are one word long, IMHO we should not be doing intra-word "contains" matching inside them. If I type "nam" I'd expect it to match NAMESPACE and UserNames, but not the SYSNAME keyword and definitely not NATIVE_COMPILATION!!!

SQL Operations Studio version: sqlops 0.32.7 (b3766d7421bac5d8596eb2ce4980da5546325282, 2018-08-30T02:48:41.576Z) OS version: Darwin x64 17.7.0

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz (8 x 2800)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
video_decode: enabled
video_encode: enabled
vpx_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|2, 2, 2| |Memory (System)|16.00GB (0.12GB free)| |Process Argv|/Applications/SQL Operations Studio.app/Contents/MacOS/Electron -psn_0_30362867| |Screen Reader|no| |VM|13%|
Extensions: none
Webbarrr commented 5 years ago

Honestly this is probably the most irritating part of Data Studio I've come across so far. On a few occasions, I've closed down ADS & gone back to working in SSMS because of how frustrating it is. I hope this gets looked at.

sql-koala commented 5 years ago

I "arrived" here with the same issue and I would also like to see a fix. Maybe I found a workaround for the time being: grafik The idea is to change the keybinding for this command (which is normally Enter). Then Enter after a table alias will behave as expected. Side effect is that you cant use Enter anymore to accept any suggestions, but if you are trained to Tab, then this should not be a problem.

edit: Changing the keybinding to Space is unintuitive in other cases, so I would just remove this keybinding.

cSharpSharp commented 1 year ago

I had the same issue and I've found an acceptable work-around for my use case: I changed the "Editor: Accept Suggestion On Enter" setting to "off". This way, I only accept autocomplete suggestion with Tab, not with Enter, which is what I am used to anyway coming from SSMS.

luigiman86 commented 11 months ago

See also https://github.com/microsoft/azuredatastudio/issues/24149 ADS needs a better way of handling aliases!