DataGrip 2022.2 EAP 2
DataGrip 2022.2 EAP build #2 is available. Let’s take a closer look at what’s inside.
Playground and Script resolve modes
Resolving database objects in SQL scripts takes an understanding of what the objects mean. This is necessary for the IDE to provide you with correct code completion and treat the usages of the objects as links.
In general, the resolve context should match the running context, but that is not a trivial task for DataGrip to handle. This is why there were, until recently, several resolve-related problems. Here’s what would sometimes happen:
- All the objects were resolved, but the script could not be run in the database.
- When the Auto-qualify option was turned on, the objects would sometimes stay unqualified if they were located in the default database/schema.
- If there were multiple objects with the same name in different databases/schemas, existing columns would fail to be resolved (or vice versa, there was a risk of resolving non-existing columns), and even the Expand column list action would sometimes generate the wrong list.
The cause of these and other issues was that, for each console or local file, DataGrip resolved their objects to the context (selected in the top right-hand drop-down) and the default database/schema (or the entry from the SQL Resolution scopes setting, if one was provided).
This was fine for working with scripts containing USE/SET SEARCH PATH statements, which switch the context. However, the IDE needs to know where to resolve right from the beginning of the file, too. So, it treated the default database/schema (or the entry from the SQL Resolution scopes setting, if one was provided) as the most appropriate context for the beginning of the file.
In other words, if there are no USE/SET SEARCH PATH statements in your file, then DataGrip shouldn’t try to resolve the beginning of the file somewhere out of context. To address this situation, we’re created a way for DataGrip to know which approach to follow, by introducing two resolve modes: Playground and Script.
In Playground mode, DataGrip resolves objects according to the context (which is the value in the schema chooser, the resolution scope, or, if none of those is set, the default database). It works best if your file is just a set of unconnected queries, independent of each other and having no particular sequence – kind of like a playground. Playground mode is now the default for query consoles.
In Script mode, the beginning of the file is resolved to the context (which is the value in the schema chooser, the resolution scope, or, if none of those is set, the default database), but any USE statements in the script change the context for the resolve because they are part of the script’s sequential logic. It is a good choice for when your queries have sequential logic and should be run as a single script. Script mode is now the default for local files.
Switching between the modes is easy – just use the drop-down on the toolbar (see the screenshot above).
That’s all for today. Please let us know what you think about these changes.
The DataGrip team