Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix for Bug#180134 - Error in one query makes subsequent queries fail

  • Loading branch information...
commit 534f7ab4aeede56c60caff5fcfa51646face22c4 1 parent dd2fbdb
@anandology anandology authored
Showing with 13 additions and 4 deletions.
  1. +12 −3 test/db.py
  2. +1 −1  web/db.py
View
15 test/db.py
@@ -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')
@@ -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"
View
2  web/db.py
@@ -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'):
Please sign in to comment.
Something went wrong with that request. Please try again.