summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-06-16 18:41:54 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-06-16 18:41:54 -0400
commit3ebb7d8e942ded31efbdb052ae3a1f08a6fc3d3d (patch)
tree6f5494b3732689c822a6b77891c6cc622322e206 /test
parent2528595802a7900e1a61570d7228bd445b5b7f3f (diff)
downloadsqlalchemy-3ebb7d8e942ded31efbdb052ae3a1f08a6fc3d3d.tar.gz
- [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.
Diffstat (limited to 'test')
-rw-r--r--test/engine/test_execute.py54
-rw-r--r--test/lib/requires.py8
2 files changed, 62 insertions, 0 deletions
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', )
diff --git a/test/lib/requires.py b/test/lib/requires.py
index 2ac939112..9b9244eae 100644
--- a/test/lib/requires.py
+++ b/test/lib/requires.py
@@ -436,3 +436,11 @@ def english_locale_on_postgresql(fn):
skip_if(lambda: testing.against('postgresql') \
and not testing.db.scalar('SHOW LC_COLLATE').startswith('en'))
)
+
+def selectone(fn):
+ """target driver must support the literal statement 'select 1'"""
+ return _chain_decorators_on(
+ fn,
+ skip_if(lambda: testing.against('oracle'),
+ "non-standard SELECT scalar syntax")
+ )