Bug in work with multiple-column foreign keys

Notice: This thread is very old.
Eda
Backer | 220
+
0
-

Hi.

I have database scheme with multiple foreign keys. Support for multiple-column foreign keys in Nette\Database was announced couple months ago. However I think it is not working correctly.

Scheme:

Code in presenter:

foreach ($this->db->table('A') as $itemA) {
	foreach ($itemA->related('B') as $itemB) {
		$itemB->text;
	}
}

This code seems ok, but it is generating error:

Illegal offset type in isset or empty

Database dump:

SET NAMES utf8;
SET foreign_key_checks = 0;
SET time_zone = 'SYSTEM';
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

DROP TABLE IF EXISTS `A`;
CREATE TABLE `A` (
  `id` int(4) unsigned NOT NULL AUTO_INCREMENT,
  `order` int(4) unsigned NOT NULL,
  PRIMARY KEY (`id`,`order`),
  KEY `order` (`order`)
) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

INSERT INTO `A` (`id`, `order`) VALUES
(1,	1),
(1,	2);

DROP TABLE IF EXISTS `B`;
CREATE TABLE `B` (
  `A_id` int(4) unsigned NOT NULL,
  `A_order` int(4) unsigned NOT NULL,
  `text` text COLLATE utf8_czech_ci NOT NULL,
  KEY `A_id` (`A_id`),
  KEY `A_order` (`A_order`),
  CONSTRAINT `B_ibfk_4` FOREIGN KEY (`A_order`) REFERENCES `A` (`order`),
  CONSTRAINT `B_ibfk_3` FOREIGN KEY (`A_id`) REFERENCES `A` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

INSERT INTO `B` (`A_id`, `A_order`, `text`) VALUES
(1,	1,	'text1'),
(1,	1,	'text2'),
(1,	2,	'text3');

I use latest Nette 2.1-dev.

Last edited by Eda (2013-04-04 23:58)

hrach
Member | 1838
+
0
-

No, it wasn't announced. Only multi primary key was announced. See https://github.com/…e/issues/933