﻿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
10813	Database errors in the shell should roll back the transaction	Glenn Maynard	Aymeric Augustin	"If an SQL statement fails in Postgresql, the connection refuses to run any further SQL commands until the transaction is rolled back.  In normal operation, this is fine; but in the shell, it's a constant aggrevation.

This is related to #852, but that ticket was asking to automatically rollback inside the connection itself, which isn't good.  This ticket is only regarding the shell.  If I run a function that causes an SQL error, the shell's connection should not be left in an unusable state, forcing me to manually import db.transaction and roll back a transaction I never asked for.  The shell should catch DatabaseError and rollback before returning to the console.

The attached patch implements this.  I've only tested with Postgresql.  This does not affect IPython (which I know nothing about).

Before:

{{{
>>> obj = User(name=""Bill"")
>>> obj.save()
...
IntegrityError: duplicate key value violates unique constraint ""app_user_name_key""

>>> obj.name = ""Jim""
>>> obj.save()
...
InternalError: current transaction is aborted, commands ignored until end of transaction block
}}}

Now:

{{{
>>> obj = User(name=""Bill"")
>>> obj.save()
...
IntegrityError: duplicate key value violates unique constraint ""app_user_name_key""

>>> obj.name = ""Jim""
>>> obj.save()
>>>
}}}
"	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed		fnl diegobz	Accepted	1	0	0	1	0	0
