Skip to content
Snippets Groups Projects
Commit 5ba697ad authored by Gavin M. Roy's avatar Gavin M. Roy
Browse files

Add a bare exception around invoking psycopg2 methods

parent f6ea3623
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -8,7 +8,7 @@ The core `queries.Queries` class will automatically register support for UUIDs,
Unicode and Unicode arrays.
 
"""
__version__ = '1.10.3'
__version__ = '1.10.4'
version = __version__
 
import logging
Loading
Loading
Loading
Loading
@@ -392,7 +392,10 @@ class TornadoSession(session.Session):
 
# Get the cursor, execute the query
func = getattr(cursor, method)
func(query, parameters)
try:
func(query, parameters)
except Exception as error:
future.set_exception(error)
 
# Ensure the pool exists for the connection
self._ensure_pool_exists()
Loading
Loading
Loading
Loading
@@ -28,7 +28,7 @@ classifiers = ['Development Status :: 5 - Production/Stable',
'Topic :: Software Development :: Libraries']
 
setup(name='queries',
version='1.10.3',
version='1.10.4',
description="Simplified PostgreSQL client built upon Psycopg2",
maintainer="Gavin M. Roy",
maintainer_email="gavinmroy@gmail.com",
Loading
Loading
Loading
Loading
@@ -207,7 +207,7 @@ class SessionPublicMethodTests(testing.AsyncTestCase):
future.set_result(True)
_execute.return_value = future
obj = tornado_session.TornadoSession(io_loop=self.io_loop)
result = yield obj.callproc('foo', ['bar'])
yield obj.callproc('foo', ['bar'])
_execute.assert_called_once_with('callproc', 'foo', ['bar'])
 
@testing.gen_test
Loading
Loading
@@ -218,5 +218,17 @@ class SessionPublicMethodTests(testing.AsyncTestCase):
future.set_result(True)
_execute.return_value = future
obj = tornado_session.TornadoSession(io_loop=self.io_loop)
result = yield obj.query('SELECT 1')
yield obj.query('SELECT 1')
_execute.assert_called_once_with('execute', 'SELECT 1', None)
@testing.gen_test
def test_query_error_key_error(self):
obj = tornado_session.TornadoSession(io_loop=self.io_loop)
with self.assertRaises(KeyError):
yield obj.query('SELECT * FROM foo WHERE bar=%(baz)s', {})
@testing.gen_test
def test_query_error_index_error(self):
obj = tornado_session.TornadoSession(io_loop=self.io_loop)
with self.assertRaises(IndexError):
yield obj.query('SELECT * FROM foo WHERE bar=%s', [])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment