How to invoke autocomplete for table names (from data source) in .sql file?

I setted up Data Source (MySQL, local server, root username/password). I have autocomplete for tables names in database console tab. How I can get autocomplete at least for tables names in .sql files?
Both Ctrl+Space and Shift+Ctrl+Space deosn't help. See image below.
sql_file_no_autocomplete_for_tables.png
P.S.
OS: Win 7 x32;
JDK: 1.6.0_18-b07;
MySQL: 5.0.45-community-nt;
WebIDE(PhpStorm): from 94.583 down to 94.5 or even to more old versions.

0
9 comments

Please check my answer in this post. I use DB navigator for mysql databases and autocomplete works ok.

http://www.jetbrains.net/devnet/thread/287297?tstart=0

0

Yes, I know about Database Navigator plugin. But WebIDE developers says in the blog there should be autocomplete with bundled plugin Database Support. Therefore my question is, how to invoke autocompletion without Database Navigator.

Currently I don't wish to use Dabase Navigator because it is too slow for me. WebIDE works much faster without it (I tried it on EAP 94.5, maybe now it works faster). And I don't need most of their features. Features of Database Support are enough for me. Currently I can invoke autocomplete for tables and fields names in db console tool window and in sql-injected strings in .php files. All what I need is autocomplete in .sql files too.

0

All the tables are in "reduinda_work" database (schema/catalog) which is not imported by default.
So you have to do any of the following:

  • specify "<database>." before each table reference and there will be completion after dot
  • use MySQL "use" statement, i.e. "use <database>;"
  • have "/<database>" part in the Database URL property of the DataSource, i.e. jdbc:mysql://<host>/<database>


The third variant is the best for MySQL.

BTW it seems that SQL Resolve inspection is turned off because all the tables in the file should be yellow.

0
have "/<database>" part in the Database URL property of the DataSource, i.e. jdbc:mysql://<host>/<database>

My db source has exactly the same settings. See image below. But there is no autocomplete in .sql files.
datasource_settings.png

BTW it seems that SQL Resolve inspection is turned off because all the tables in the file should be yellow.

No, I didn't turn off inspections. See image below.
inspections_on.png

0

Please ensure that MySQL dialect is configured in Settings/SQL Dialects.
The Generic dialect provides only keyword highlighing and completion so this setting may be the cause of the problem.
If this is not the case then I have to ask some more questions:

Does "Go to declaration" (Ctrl+B) works on `se_languagevars` for example?
Do you have completion in the following sample queries:
"select * from reduinda_<caret-here>"
"select * from reduinda_work.<caret-here>

As far as inspections are concerned the "highlighting level" popup is not enough. You should check whether the SQL inspections are turned on in the inspection profile settings. To check the profile just click on the "Configure Inspections" link that is located under the "Highlighting Level" slider.

2

Thank you, Gregory! I didn't selected SQL dialect for my files. There was a problem. But after selecting MySQL dialect the WebIDE started throwing a lot of errors like this:

Element: class com.intellij.psi.impl.source.tree.PsiCommentImpl: Element: class com.intellij.psi.impl.source.tree.PsiCommentImpl
com.intellij.psi.PsiInvalidElementAccessException: Element: class com.intellij.psi.impl.source.tree.PsiCommentImpl
at com.intellij.psi.impl.source.tree.LeafPsiElement.getContainingFile(LeafPsiElement.java:83)
at com.intellij.lang.folding.FoldingDescriptor.getRange(FoldingDescriptor.java:106)
at com.intellij.lang.folding.FoldingDescriptor.getRange(FoldingDescriptor.java:101)
at com.intellij.codeInsight.folding.impl.UpdateFoldRegionsOperation.a(UpdateFoldRegionsOperation.java:96)
at com.intellij.codeInsight.folding.impl.UpdateFoldRegionsOperation.run(UpdateFoldRegionsOperation.java:68)
at com.intellij.openapi.editor.impl.FoldingModelImpl.a(FoldingModelImpl.java:184)
at com.intellij.openapi.editor.impl.FoldingModelImpl.runBatchFoldingOperationDoNotCollapseCaret(FoldingModelImpl.java:198)
at com.intellij.codeInsight.folding.impl.FoldingUpdate$3.run(FoldingUpdate.java:92)
at com.intellij.codeInsight.daemon.impl.CodeFoldingPass.doApplyInformationToEditor(CodeFoldingPass.java:58)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.applyInformationToEditor(TextEditorHighlightingPass.java:77)
at com.intellij.codeInsight.daemon.impl.PassExecutorService.a(PassExecutorService.java:406)
at com.intellij.codeInsight.daemon.impl.PassExecutorService.access$1000(PassExecutorService.java:59)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$4.run(PassExecutorService.java:380)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:319)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at com.intellij.ide.IdeEventQueue.f(IdeEventQueue.java:610)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:500)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:368)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

0

This problem is unrelated to SQL or Database functionality.
Please use built in error reporting tool or post this trace in tracker.
Make sure you have the latest EAP installed and/or wait for the next one.

0

I reported it via built in error reporting tool. But sometimes this tool doesn't send report. And I should press send button second time, sometimes third and so on. Is it because your server is overloaded with error reports?

0

There may be various reasons. Anyway we do our best to make it available.

0

Please sign in to leave a comment.