Page 1 of 1

update foreign keys

Posted: Thu 26 Mar 2009 08:48
by axe
if I try to update primary key, which also is foreign key for other table (in gui interface ),
then primary key are not updated. (all tables have InnoDB type)

but if I update table through sql query, then both fields update normal.

Posted: Thu 26 Mar 2009 12:23
by Duke
Could you please help us to reproduce the problem?
We need scripts of these tables and the query that you ran manually.

Posted: Thu 26 Mar 2009 14:38
by axe

Code: Select all

CREATE TABLE `object` (
  `object_id` int(10) unsigned NOT NULL auto_increment,
  `obj_type` varchar(20) default NULL,
  `max_action` tinyint(3) unsigned default NULL,
  PRIMARY KEY  (`object_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 

CREATE TABLE `attributes` (
  `attr_id` varchar(100) NOT NULL,
  `component_id` int(11) unsigned NOT NULL,
  `str_id` int(11) unsigned default NULL,
  `object_id` int(10) unsigned default NULL,
  `description` varchar(255) default NULL,
  PRIMARY KEY  (`attr_id`),
  KEY `fk_attributes__object_id` (`object_id`),
  CONSTRAINT `fk_attributes__object_id` FOREIGN KEY (`object_id`) REFERENCES `object` (`object_id`) ON UPDATE CASCADE,
) ENGINE=InnoDB DEFAULT CHARSET=utf8 
no query. I can't change object.object_id in "edit table" mode

Posted: Fri 27 Mar 2009 16:02
by Duke
MySQL server does not allow renaming columns referenced in foreign key. You need to remove foreign key, change column and recreate foreign key.

Posted: Mon 30 Mar 2009 05:55
by axe
I don't change column. I change some value in column. sql query "update" normally run. If I run query

Code: Select all

 update object set object_id=31 where object_id=33;
then object_id columns change in both tables. But "edit table" mode can't change the value.

Posted: Mon 30 Mar 2009 14:39
by Duke
Unfortunately, editing values of auto-increment column is not allowed from data editor. We are working over this problem.