﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3615	Can't define forward references in fixtures using MySQL with InnoDB	Russell Keith-Magee	nobody	"The problem is highlighted by the test case introduced in [4610]. 

When using MySQL with the InnoDB backend, fixture data files (or any serialized data) can't contain forward references. If a forward reference is encountered, a row-level contraint error is raised. This is because MySQL checks constraints at the end of each command.

Postgres has similar behaviour to InnoDB by default, but [4610] modified the table declarations to disable constraint checking until the end of a transaction using ``DEFFERABLE INITIALLY DEFERRED``. However, MySQL doesn't implement this feature or an equivalent.

If you have your MySQL setup to use MyISAM (the default backend), you won't see the problem, because MyISAM doesn't enforce constraints.

One way around the problem would be to use ``SET FOREIGN_KEY_CHECKS=0`` at the start and ``SET FOREIGN_KEY_CHECKS=1`` at the end of each transaction (or around the serialization/fixture use). However, this wouldn't validate any keys modified while the checks were disabled.
"	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed	mysql innodb myisam reference fixture	andrew@… tonightslastsong@… eduardocereto@… chris@… maxirobaina@… tomasz.zielinski@… Jim Dalton	Accepted	1	0	0	1	0	0
