Git Product home page Git Product logo

Comments (6)

kristijanhusak avatar kristijanhusak commented on May 21, 2024 1

I have an old and low priority todo for myself to add scoping to schema, but I never got to it since I didn't run into this issue myself, so it didn't bother me much.

Parsing aliases from current query is too simple to be reliable, that's why i return everything that matches for it. Better to have more things than to miss something.

I believe that in real life database you will not have these issues, since table naming should be better and longer, and short aliases should work out fine.

Anyway, thanks for reporting. Now I at least know that someone really ran into these issues.

from vim-dadbod-completion.

kristijanhusak avatar kristijanhusak commented on May 21, 2024

Does it happen if you use any other alias, or only with sp? Are you using any other source beside dadbod-completion for the sql buffer?
Also, what happens if you do omni completion (<C-x><C-o>) after sp.? Are results ok in that case?

from vim-dadbod-completion.

CarbonChauvinist avatar CarbonChauvinist commented on May 21, 2024

Yes it happens with other aliases as well, it seems that name and id are always included in the list despite the schema.table that I'm attempting to alias. The other incorrect entries appear to be a mix of table names or other column/schema names at times.

The only other source I'm using for sql buffers is buffer, and now that I've fixed the menu text with your help I can see the source is all from Text [DB].

Trying to use the omni completion with an alias also provides the same incorrect entries, but switching to the full schema.table shows the correct column list with both omni-completion and vim-dadbod-completion.

dadbodcmp.mp4

from vim-dadbod-completion.

kristijanhusak avatar kristijanhusak commented on May 21, 2024

Do you happen to have same tables in multiple schemas?
Also, is there any chance to get access to your db, or at least just a structure dump?
It's hard to debug this without the database, I can only guess what's happening.

from vim-dadbod-completion.

CarbonChauvinist avatar CarbonChauvinist commented on May 21, 2024

I used this to setup the sample adventure works database for postgres

https://github.com/lorint/AdventureWorks-for-Postgres

I'm not as familiar with the setup of this database as yet, as I'm using for learning/testing. However your comment made me do some more digging.

Yes! There is a table named 'sp' albeit under the 'pe' schema. And it has all the columns that are coming through when attempting to use the alias 'sp'.

Screenshot from 2021-08-31 16-03-06

Also, there's also a table named 's', under the 'hr' schema, which I imagine has the same column values that are coming through when trying to use that as an alias.

Screenshot from 2021-08-31 19-36-51

I guess there's no way for the completion to realize if you're attempting to complete from an alias vs from a column from a table even if it's in a different schema?

Is there another way to get the behavior I was expecting (i.e. force full reference of schema.table.column for completion results)? Or is it just ignorance on my part? If so I apologize for the noise.

from vim-dadbod-completion.

CarbonChauvinist avatar CarbonChauvinist commented on May 21, 2024

Closing this issue as it appears to be an ignorant mistake on my part (I was attempting to use aliases that were already table names in the database).

Ideally, autocomplete would be able to, in the select or where blocks, limit the scope of returned columns to only the tables listed in the from block of the current query, though I understand that's probably not possible in practice.

Thanks for creating and sharing this very useful plugin.

from vim-dadbod-completion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.