From 3ebb7d8e942ded31efbdb052ae3a1f08a6fc3d3d Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 16 Jun 2012 18:41:54 -0400 Subject: - [bug] The ResultProxy methods inserted_primary_key, last_updated_params(), last_inserted_params(), postfetch_cols(), prefetch_cols() all assert that the given statement is a compiled construct, and is an insert() or update() statement as is appropriate, else raise InvalidRequestError. [ticket:2498] - ResultProxy.last_inserted_ids is removed, replaced by inserted_primary_key. --- test/engine/test_execute.py | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'test/engine') diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index 7ccd42b73..2b6dd1c09 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -896,6 +896,60 @@ class ResultProxyTest(fixtures.TestBase): writer.writerow(row) assert s.getvalue().strip() == '1,Test' + @testing.requires.selectone + def test_empty_accessors(self): + statements = [ + ( + "select 1", + [ + lambda r: r.last_inserted_params(), + lambda r: r.last_updated_params(), + lambda r: r.prefetch_cols(), + lambda r: r.postfetch_cols(), + lambda r : r.inserted_primary_key + ], + "Statement is not a compiled expression construct." + ), + ( + select([1]), + [ + lambda r: r.last_inserted_params(), + lambda r : r.inserted_primary_key + ], + r"Statement is not an insert\(\) expression construct." + ), + ( + select([1]), + [ + lambda r: r.last_updated_params(), + ], + r"Statement is not an update\(\) expression construct." + ), + ( + select([1]), + [ + lambda r: r.prefetch_cols(), + lambda r : r.postfetch_cols() + ], + r"Statement is not an insert\(\) " + r"or update\(\) expression construct." + ), + ] + + for stmt, meths, msg in statements: + r = testing.db.execute(stmt) + try: + for meth in meths: + assert_raises_message( + tsa.exc.InvalidRequestError, + msg, + meth, r + ) + + finally: + r.close() + + class AlternateResultProxyTest(fixtures.TestBase): __requires__ = ('sqlite', ) -- cgit v1.2.1