Page 1 of 1

Circular reference causing error - how do I get around this?

Posted: Mon 13 Jun 2011 15:37
by Altreus
Hi.

We are trialling dbForge for possible adoption by our company. It all looks good so far except for one thing, which is the only black mark we have against the software.

Anyway: We are working with it on existing databases, which have so far been maintained awkwardly with a combination of phpMyAdmin and luck. One such database has two tables - call them A and B - which reference one another as foreign key.

Code: Select all

CREATE TABLE A (
  id int auto_increment primary key,
  id_b int auto_increment
);

CREATE TABLE B (
  id int auto_increment primary key,
  id_a int auto_increment
);

ALTER TABLE A ADD FOREIGN KEY (id_b) REFERENCES (B.id);
ALTER TABLE B ADD FOREIGN KEY (id_a) REFERENCES (A.id);
Unfortunately, it doesn't seem like dbForge can cope with this. When we try to synchronise, it throws up errors for our analogues of these tables. It recommends reordering the build: but of course it is impossible to reorder the build correctly because you cannot both declare A before B and declare B before A.

As with the SQL above, the correct answer is to first create A and B, and then alter them to create the two foreign keys.

My question is, can I resolve this easily? I would prefer to have dbForge be aware of the two constraints, so the ideal solution to the problem would be simply to tell it to defer these constraints, or at least to somehow have the indices show up separately from the table itself in the build order dialogue.

Thanks in advance

Posted: Tue 14 Jun 2011 06:21
by .jp
Please answer the following questions:
1) What version of MySQL Server are you using?
2) Which build of dbForge Studio for MySQL are you using (you can find this information on the About window)?
3) Which edition of dbForge Studio for MySQL are you using (trial of express)?
4) In what functionality did you find this problem, in Schema Comparer or Database Project?

Posted: Tue 14 Jun 2011 07:58
by Altreus
1) MySQL Server version: 5.0.77
2) 5.0.33
3) Trial
4) It was while trying to build a project, but the same happens when running the Schema Comparer so I guess this is the first thing the project builder runs.

Thank you :)

Posted: Tue 14 Jun 2011 13:21
by Viktor
Please check if the "Load completions from database" option is checked (Tools->Options->Text Editor->Code Completion).
After checking the "Load completions from database" option, reopen the connection and try to synchronize your databases.

Posted: Tue 14 Jun 2011 13:30
by Altreus
The box is already ticked.

Posted: Fri 17 Jun 2011 15:13
by Viktor
Please download a new build. The latest build if 5.0.36. We have released it today.
We made lots of fixes in it. Please download the latest version and check whether the error persists.