QueryFlag: Troubleshooting
Find the symptom below and follow the steps to fix it.
Query Flag in DB is missing from the context menu
The editor context menu shows Query Flag in DB only when at least one template can run in the current project.
If you have no templates yet, create one.
If your templates use a data source of another project, open that project and make the data source global (see Where templates are available), or create a template for a data source of this project.
Make sure the Database Tools and SQL plugin and QueryFlag are enabled in . The IDE disables QueryFlag when it has no active trial or license; see Start the trial or activate a license.
The query results do not appear
By default, QueryFlag runs the query in a new query console that does not open in the editor. Look for the results in the Services tool window.
Select (Alt+8, macOS: ⌘ 8) and look under the template's data source.
If the Services tool window does not open after a run, make sure that Show Services tool window for query execution output is not set to Never in (DataGrip: ).
If QueryFlag shows the warning "Query with blank text is disable, skipping execution", see QueryFlag skips the run because the selection is blank.
If the data source cannot connect, you get a connection error instead of results. See The query does not connect.
A template shows DataSource not found
The settings list shows the red text "DataSource not found, please check your Databases settings" for a template whose data source is not available in the current project. This happens when the template belongs to another project, or when the data source was deleted and created again. Templates refer to data sources by ID, so renaming a data source does not cause it.
If the template belongs to another project, leave it as it is; it works there. To use it in this project too, make its data source global; see Where templates are available. Otherwise, connect it to a data source of this project:
Connect the template to a data source
In , select the template and click Edit.
Select a data source in DataSource and click OK.
Click Apply.
The template dialog does not accept the query
When you click OK in the Add a QueryFlag Entry dialog, QueryFlag checks the fields:
- QueryFlagName cannot be empty
Enter a Name.
- Database cannot be empty
Select a DataSource. If the list is empty, add a data source in the Database tool window first.
- Database query cannot be empty
Enter a query in QueryFlag with Token.
- Database query must contain at least one <QFToken> replacement
Add the token
<QUERY_FLAG_TOKEN>to the query. The message says<QFToken>, but the token that QueryFlag replaces is<QUERY_FLAG_TOKEN>.
QueryFlag skips the run because the selection is blank
QueryFlag shows the warning "Query with blank text is disable, skipping execution". You ran a template with an empty selection, or a selection with only spaces. Select the value in the editor and run the template again.
QueryFlag also treats the selection as empty in editors that do not show a file, such as the diff viewer. Run the template from an editor tab instead.
To run templates with an empty value on purpose, select Allow blank Text in the QueryFlag settings.
The query fails with an error
Make sure the template quotes the token where the query needs a string literal, for example
WHERE key = '<QUERY_FLAG_TOKEN>'. See Write the template query.If the selected value contains a single quote, the SQL string ends early. Select only the part of the value without the quote.
If the database reports that a table does not exist, or that no schema or database is selected, qualify the table name in the template with its schema or database, for example
demo.customers. Each run uses a new query console, and its current schema can differ from the one in the console where you wrote the query.To see the exact query that ran, select Open console editor in the QueryFlag settings and run the template again.
Add Query Flag is missing from the context menu
Add Query Flag appears only in an editor that is connected to a data source, such as a query console, and only when you select some text first. To create a template from a query in another file, copy the query into a query console of the data source, or add the template in Settings.
The query field highlights the wrong language
The query field uses the query language of the data source that is selected when the dialog opens. Save the template, then open it again with Edit: the field now uses the language of the template's data source. You can also create the template from a query console of that data source.
The query does not connect
QueryFlag runs the query through the data source of the Database tool window. If the data source cannot connect, for example because its driver files are missing or its credentials are wrong, check the data source:
Test the data source connection
In the Database tool window, right-click the data source and select Properties.
Click Test Connection.
Fix the reported problem and click OK.
Report a problem
If the IDE shows a QueryFlag error, click Report Exception in the error dialog. For details and other ways to get help, see Report a bug or request a feature.