Skip to content

Commit

Permalink
fix for Bug#180134 - Error in one query makes subsequent queries fail
Browse files Browse the repository at this point in the history
  • Loading branch information
anandology committed Jan 3, 2008
1 parent dd2fbdb commit 534f7ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions test/db.py
Expand Up @@ -5,11 +5,12 @@
class DBTest(webtest.TestCase):
dbname = 'postgres'

def setUpAll(self):
def setUp(self):
web.config._hasPooling = False
webtest.setup_database(self.dbname)
web.query("CREATE TABLE person (name text, email text)")
web.query("CREATE TABLE person (name text unique, email text)")

def tearDownAll(self):
def tearDown(self):
# there might be some error with the current connection, delete from a new connection
webtest.setup_database(self.dbname)
web.query('DROP TABLE person')
Expand All @@ -18,6 +19,14 @@ def testUnicode(self):
"""Bug#177265: unicode queries throw errors"""
web.select('person', where='name=$name', vars={'name': u'\xf4'})

def testWrongQuery(self):
# It should be possible to run a correct query after getting an error from a wrong query.
try:
web.select('wrong_table')
except:
pass
web.select('person')

class SqliteTest(DBTest):
dbname = "sqlite"

Expand Down
2 changes: 1 addition & 1 deletion web/db.py
Expand Up @@ -358,7 +358,7 @@ def db_execute(cur, sql_query, dorollback=True):
except:
if web.config.get('db_printing'):
print >> web.debug, 'ERR:', str(sql_query)
if dorollback: rollback(care=False)
if dorollback and not web.ctx.db_transaction: web.ctx.db.rollback()
raise

if web.config.get('db_printing'):
Expand Down

0 comments on commit 534f7ab

Please sign in to comment.