DataGrip fails to draw correct diagram

Answered

DataGrip ignores some of the foregn keys of a MySQL db.

0
11 comments

What IDE version do you use? Could you please provide the DDL examples for the tables which do not have the keys on diagram?

0
Avatar
Permanently deleted user

This is an example of two tables imported from MySQL db. For some reason most of the foreign key are not drawn as you can see here,

0

What IDE version do you use? Please add the DDL for these tables.

0
Avatar
Permanently deleted user

I don't know what was the version of DataGrip but it was the latest on the site.

 

Here are two of the tables that misbehave:

CREATE TABLE `Building` (
`id` int(11) NOT NULL,
`description` varchar(45) NOT NULL,
`managedGridId` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `BuildingAddress` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`managedGridId` int(11) NOT NULL,
`buildingId` int(11) DEFAULT NULL,
`addressId` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_BuildingAddress_Building1_idx` (`buildingId`),
KEY `fk_BuildingAddress_Address1_idx` (`addressId`),
CONSTRAINT `fk_BuildingAddress_Address1` FOREIGN KEY (`addressId`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
CONSTRAINT `fk_BuildingAddress_Building1` FOREIGN KEY (`buildingId`) REFERENCES `building` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;

0

in the `FOREIGN KEY` reference clause you have `building` referenced with the small letter, but create table statement uses capital B. When I change it to capital letter and create the script it works:

Does it help?

0
Avatar
Permanently deleted user

Thanks. I understand, but this is what I get from MySQL, which leaves me without a solution. I think MySQL behaves that way because it is installed on a Windows platform which is case insensitive.

0

Not sure I understand completely, could you clarify? I also tested it on Windows. How did you get the DDL, shown in previous message? Have you configured any additional jdbc properties for data source (e.g. in Advanced tab or in jdbc URL)? Please also attach Details output from Test Connection button for the Data Source. Thank you. It would be great to understand how we could reproduce the issue.

0
Avatar
Permanently deleted user

I have not touched the advanced settings, so it is all defaults.

Here are the Details from Test Connection:

Database: MySQL (ver. 5.7.20-log) Identifier case sensitivity: mixed (plain), upper (delimited) Driver (JDBC4.0): MySQL Connector Java (ver. mysql-connector-java-5.1.46 ( Revision: 9cc87a48e75c2d2e87c1a293b2862ce651cb256e ))

 

The DDL came from MySQL Workbench.

0

>The DDL came from MySQL Workbench.

Could you please provide the DDL as is shown by IDE for these tables?

Please also try if it helps to invoke Forget Cached schemas and re-synchronize the Data Source (step 4 in Resolving visualization problems). Thank you.

0
Avatar
Permanently deleted user

It produced the same results after re-synchronization.

 

Here is the DDL from the IDE:

create table Building
(
id int not null
primary key,
description varchar(45) not null,
managedGridId int not null
)
engine=InnoDB charset=latin1
;
create table BuildingAddress
(
id int auto_increment
primary key,
managedGridId int not null,
buildingId int null,
addressId int null,
constraint fk_BuildingAddress_Building1
foreign key (buildingId) references building (id)
on delete set null
)
engine=InnoDB charset=latin1
;

create index fk_BuildingAddress_Address1_idx
on BuildingAddress (addressId)
;

create index fk_BuildingAddress_Building1_idx
on BuildingAddress (buildingId)
;

0

Thank you for details. I've filled the https://youtrack.jetbrains.com/issue/DBE-6225 issue. Please vote and follow for updates.

0

Please sign in to leave a comment.