mrn3 / data-ace

Atom package that enables you to connect to, query, manage, and analyze databases
MIT License
0 stars 2 forks source link

autocompletion with database and tables not working #2

Open kylegrieder opened 6 years ago

kylegrieder commented 6 years ago

I can't get databases or tables to load, which means autocompletion for fields isn't working either.

I'm able to connect and run queries, but when I click the "Database" drop down in the connection window, nothing appears. Any idea what the problem might be?

mrn3 commented 6 years ago

yeah, this might not be in a totally workable state. it might work for mysql, but not so much for postgresql, or vice versa. I haven't actively been working on this for a while, so I am not sure I can help much more, but if you want to help dig into the code, I think we can resolve your issue.

kylegrieder commented 6 years ago

I’m using this with Amazon Redshift, which is a variation of PostgreSQL. I can look at the code, but I don’t know if that will be much help. But I can do my best to make sense of it. I’ll let you know what I find, if I find anything.

On Jan 11, 2018, at 11:05 PM, Matt Newman notifications@github.com wrote:

yeah, this might not be in a totally workable state. it might work for mysql, but not so much for postgresql, or vice versa. I haven't actively been working on this for a while, so I am not sure I can help much more, but if you want to help dig into the code, I think we can resolve your issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mrn3/data-ace/issues/2#issuecomment-357151310, or mute the thread https://github.com/notifications/unsubscribe-auth/AYPxZYEsyu-k8L5VSKP4tbrweePgbwkZks5tJvY8gaJpZM4Rbo31.

mrn3 commented 6 years ago

Okay, yeah, I used it with Redshift too, but I hadn't sorted everything out. It is tricky because Redshift/Postgres has databases, schemas, and tables, but MySQL only has databases and tables, so there is another level of hierarchy with Redshift.

kylegrieder commented 6 years ago

I found an issue, but I'm not sure how to solve it completely.

In lib\data-managers\redshift-manager.js, in getDatabaseNames(), there is an if statement in place for building the query to retrieve databases. It seems to have something to do with being a super-user for the database. I removed the if statement and simply replaced the whole thing with

let query = 'SELECT datname FROM pg_database WHERE datistemplate = false ORDER BY datname;'

I realize its not ideal, but for my purposes it seems to work. Now, when connecting via the New Connection modal, databases are retrieved and when I select a database, the various schemas are retrieved.

This is where I'm running into trouble though. Autocomplete still isn't working, and I noticed that it seems like there should be a tree view of the associated tables and columns once a schema is selected, but that doesn't show up either. I looked at lib\views\details-view.js, at the buildTableList() function. I noticed on line 97 that you're calling this.DBManager.getTables(database), however in redshift-manager.js, the getTables() function expects 2 parameters - database, and schemaName. I believe this might be why tables aren't being retrieved, and therefore no table tree view is appearing.

This is where I kind of got lost. I'm also at work right now and can't spend any more time on it, but I wanted to update you on what I found so far. I'm not super familiar with javascript, and I'm only a junior developer anyway, so I'm not sure it would be an efficient use of my time to delve into this further, at least not while I'm working.

I'll continue to look at it sometime tonight when I get home, but I wanted to update you on my progress. Thanks for your time.

mrn3 commented 6 years ago

yeah, thanks for looking into that. this sounds like the issues I was trying to fix with the hierarchy being different on postgres/redshift than mysql. I ended up mostly abandoning the project as I have moved on and don't really use this anymore. So, I am not sure I will actively be fixing this issue, but if you want to take over the project or just do a pull request to fix this, I am open to it.