8/30/2023 0 Comments Datagrip documentation![]() ![]() Generated pattern is a result that is generated by the replacement pattern in Target column pattern. Generated pattern: a generated read-only regular expression pattern that is matched to the Target lumn name. Source column: an example of a column name that you want to use as a virtual foreign key. Ensure that you double-escaped symbols that are translated literally like the dot in the example expression ( $1\\.(?i)id). Note: the Target column pattern replacement pattern is used to generate a regular expression pattern in the Generate pattern field with captured groups. This expression will generate visitor.id reference that we can use as a primary key. Note that the result appears only when you give an example of a column name in the Source column field.įor example, we can use the captured group ( $1) from the Column pattern expression, add a dot (. You can see the result in the Generated pattern field. Target column pattern: the replacement pattern that uses the match from the Column pattern expression and is interpreted as a regular expression. This regular expression will find columns like visitor_id or visitor_Id, and capture visitors as the first capturing group ( $1). In the Rule debugger dialog, fill the following fields:Ĭolumn pattern: the regular expression that will match a column name that you want to use as a virtual foreign key.įor example, to describe columns that use the _id postfix, use the (.*)_(?i)id regular expression. Select the rule and click the Check button ( ). The resulted expression in the Generated pattern field must match the desired Target lumn pattern. When you select the rule and click the Check button, the Rule debugger dialog opens. You can check your rules by using the Check button ( ). The replacement pattern uses the match from the Column pattern expression and is interpreted as a regular expression. ![]() Open settings ( Control+Alt+S) and navigate to Database | Other.ĭouble-click the Column pattern cell and type the regular expression that will match a column name that you want to use as a virtual foreign key.ĭouble-click the Target column pattern cell and type the replacement pattern. You can use regular expressions to create a rule according to which DataGrip will point a column in one table to a column in another table. To change or see the path to the XML document, open data source settings by pressing Command, click the Options tab and see the Virtual objects and attributes field. You can select other name for the XML file and other place to store this file. The relation is saved in external-data.xml. Create a virtual foreign keyĬlick the table relation in the ON clause and press Alt+Enter. You can see a reference on node and object icons in the Icons for data sources and their elements chapter of Database Explorer topic.įor the table column icons, refer to Possible icon combinations for columns. Virtual foreign keys can be seen in the Database Explorer. ![]() If you have foreign keys pointing to the objects in another schema and these objects have the same names, they will be displayed as qualified in the navigation dialog for foreign keys. You can save this relation and use it later or configure rules for virtual foreign keys in settings by using regular expressions. You can still use this virtual relation between the visitor_id field in the activity table and the id field in the visitor table in this JOIN clause. Let's assume that visitor_id is not defined as a foreign key in the database. ![]() SELECT * FROM activity JOIN visitor ON visitor_id = visitor.id ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |