From e8f97c9e357ed0793ce11086823f83aa4a8bb4ad Mon Sep 17 00:00:00 2001 From: Jack Zhou Date: Tue, 31 May 2016 10:01:46 -0400 Subject: Add SKIP LOCKED support for Postgresql, Oracle This adds `SELECT ... FOR UPDATE SKIP LOCKED`/ `SELECT ... FOR SHARE SKIP LOCKED` rendering. Change-Id: Id1dc4f1cafc1de23f397a6f73d54ab2c58d5910d Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/86 --- test/dialect/postgresql/test_compiler.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/dialect/postgresql/test_compiler.py') diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index c20e48b01..c061cfaf1 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -605,6 +605,13 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "SELECT mytable.myid, mytable.name, mytable.description " "FROM mytable WHERE mytable.myid = %(myid_1)s FOR UPDATE NOWAIT") + self.assert_compile( + table1.select(table1.c.myid == 7). + with_for_update(skip_locked=True), + "SELECT mytable.myid, mytable.name, mytable.description " + "FROM mytable WHERE mytable.myid = %(myid_1)s " + "FOR UPDATE SKIP LOCKED") + self.assert_compile( table1.select(table1.c.myid == 7).with_for_update(read=True), "SELECT mytable.myid, mytable.name, mytable.description " @@ -616,6 +623,13 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "SELECT mytable.myid, mytable.name, mytable.description " "FROM mytable WHERE mytable.myid = %(myid_1)s FOR SHARE NOWAIT") + self.assert_compile( + table1.select(table1.c.myid == 7). + with_for_update(read=True, skip_locked=True), + "SELECT mytable.myid, mytable.name, mytable.description " + "FROM mytable WHERE mytable.myid = %(myid_1)s " + "FOR SHARE SKIP LOCKED") + self.assert_compile( table1.select(table1.c.myid == 7). with_for_update(of=table1.c.myid), @@ -645,6 +659,14 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "FROM mytable WHERE mytable.myid = %(myid_1)s " "FOR SHARE OF mytable NOWAIT") + self.assert_compile( + table1.select(table1.c.myid == 7). + with_for_update(read=True, skip_locked=True, + of=[table1.c.myid, table1.c.name]), + "SELECT mytable.myid, mytable.name, mytable.description " + "FROM mytable WHERE mytable.myid = %(myid_1)s " + "FOR SHARE OF mytable SKIP LOCKED") + ta = table1.alias() self.assert_compile( ta.select(ta.c.myid == 7). -- cgit v1.2.1