summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-02-09 18:11:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-02-09 18:11:40 -0500
commit7e8f35109725ed3fd3caf96acf8b94a13c53fdfe (patch)
tree6ee96b736322eff04bb1ec5ff2b6e9de84e5545c /test/sql
parente80eac22a8669ada5ffaabbcfa8a991eee140697 (diff)
downloadsqlalchemy-7e8f35109725ed3fd3caf96acf8b94a13c53fdfe.tar.gz
- Non-DBAPI errors which occur in the scope of an `execute()`
call are now wrapped in sqlalchemy.exc.StatementError, and the text of the SQL statement and repr() of params is included. This makes it easier to identify statement executions which fail before the DBAPI becomes involved. [ticket:2015]
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_constraints.py8
-rw-r--r--test/sql/test_defaults.py4
-rw-r--r--test/sql/test_query.py8
3 files changed, 10 insertions, 10 deletions
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py
index 4bacbd271..f4791c0bd 100644
--- a/test/sql/test_constraints.py
+++ b/test/sql/test_constraints.py
@@ -79,9 +79,9 @@ class ConstraintTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
metadata.create_all()
foo.insert().execute(id=1,x=9,y=5)
- assert_raises(exc.SQLError, foo.insert().execute, id=2,x=5,y=9)
+ assert_raises(exc.DBAPIError, foo.insert().execute, id=2,x=5,y=9)
bar.insert().execute(id=1,x=10)
- assert_raises(exc.SQLError, bar.insert().execute, id=2,x=5)
+ assert_raises(exc.DBAPIError, bar.insert().execute, id=2,x=5)
def test_unique_constraint(self):
foo = Table('foo', metadata,
@@ -98,8 +98,8 @@ class ConstraintTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
foo.insert().execute(id=2, value='value2')
bar.insert().execute(id=1, value='a', value2='a')
bar.insert().execute(id=2, value='a', value2='b')
- assert_raises(exc.SQLError, foo.insert().execute, id=3, value='value1')
- assert_raises(exc.SQLError, bar.insert().execute, id=3, value='a', value2='b')
+ assert_raises(exc.DBAPIError, foo.insert().execute, id=3, value='value1')
+ assert_raises(exc.DBAPIError, bar.insert().execute, id=3, value='a', value2='b')
def test_index_create(self):
employees = Table('employees', metadata,
diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py
index 1f2226842..cbecdbe18 100644
--- a/test/sql/test_defaults.py
+++ b/test/sql/test_defaults.py
@@ -304,7 +304,7 @@ class DefaultTest(testing.TestBase):
12, today, 'py')])
def test_missing_many_param(self):
- assert_raises_message(exc.InvalidRequestError,
+ assert_raises_message(exc.StatementError,
"A value is required for bind parameter 'col7', in parameter group 1",
t.insert().execute,
{'col4':7, 'col7':12, 'col8':19},
@@ -531,7 +531,7 @@ class AutoIncrementTest(_base.TablesTest):
nonai.insert().execute(data='row 1')
nonai.insert().execute(data='row 2')
assert False
- except sa.exc.SQLError, e:
+ except sa.exc.DBAPIError, e:
assert True
nonai.insert().execute(id=1, data='row 1')
diff --git a/test/sql/test_query.py b/test/sql/test_query.py
index cbf6e6e58..359084cd8 100644
--- a/test/sql/test_query.py
+++ b/test/sql/test_query.py
@@ -48,8 +48,8 @@ class QueryTest(TestBase):
def test_insert_heterogeneous_params(self):
"""test that executemany parameters are asserted to match the parameter set of the first."""
- assert_raises_message(exc.InvalidRequestError,
- "A value is required for bind parameter 'user_name', in parameter group 2",
+ assert_raises_message(exc.StatementError,
+ "A value is required for bind parameter 'user_name', in parameter group 2 'INSERT INTO query_users",
users.insert().execute,
{'user_id':7, 'user_name':'jack'},
{'user_id':8, 'user_name':'ed'},
@@ -852,8 +852,8 @@ class QueryTest(TestBase):
def test_cant_execute_join(self):
try:
users.join(addresses).execute()
- except exc.ArgumentError, e:
- assert str(e).startswith('Not an executable clause: ')
+ except exc.StatementError, e:
+ assert str(e).startswith('Not an executable clause ')