﻿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
22431	TestCase swallows IntegrityError when creating object with invalid foreign key	Chris Jerdonek	nobody	"Django's TestCase class seems to swallow `IntegrityErrors` when creating and saving an object when a foreign key is manually specified that is invalid.

When calling `save()` in this case, no exception is raised, and the object returned by `save()` is given a valid `id`.  However, the object is not actually saved to the database.  When switching from `TestCase` to `TransactionTestCase`, the error is raised as expected when saving, and the error looks something like the following:

{{{
IntegrityError: insert or update on table ""app_table1"" violates foreign key constraint ""app_table1_table2_id_fkey""
DETAIL:  Key (table2_id)=(X) is not present in table ""app_table2"".
}}}
"	Cleanup/optimization	closed	Documentation	1.6	Normal	duplicate	TestCase,IntegrityError,TransactionTestCase,ForeignKey	Simon Charette	Accepted	0	0	0	0	0	0
