[CalendarServer-changes] [15170] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 7 09:31:40 PDT 2015


Revision: 15170
          http://trac.calendarserver.org//changeset/15170
Author:   cdaboo at apple.com
Date:     2015-10-07 09:31:40 -0700 (Wed, 07 Oct 2015)
Log Message:
-----------
Latest twext to handle Oracle style pl/sql create function blocks.

Modified Paths:
--------------
    CalendarServer/trunk/requirements-stable.txt
    CalendarServer/trunk/txdav/common/datastore/test/test_sql_tables.py

Modified: CalendarServer/trunk/requirements-stable.txt
===================================================================
--- CalendarServer/trunk/requirements-stable.txt	2015-10-07 16:30:40 UTC (rev 15169)
+++ CalendarServer/trunk/requirements-stable.txt	2015-10-07 16:31:40 UTC (rev 15170)
@@ -36,7 +36,7 @@
             #pyOpenSSL
         pycrypto==2.6.1
 
-    --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@15161#egg=twextpy
+    --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@15169#egg=twextpy
         cffi==1.1.0
             pycparser==2.13
         #twisted

Modified: CalendarServer/trunk/txdav/common/datastore/test/test_sql_tables.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/test_sql_tables.py	2015-10-07 16:30:40 UTC (rev 15169)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_sql_tables.py	2015-10-07 16:31:40 UTC (rev 15170)
@@ -422,6 +422,67 @@
         self.assertRaises(StopIteration, result.next)
 
 
+    def test_returnTwoPlSQLCreateOrReplace(self):
+        """
+        One pl/sql block yields a single string
+        """
+        plsql = """create or replace function next_job_all(now timestamp)
+  return integer is
+  cursor c1 is
+   select JOB_ID from JOB
+   where ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
+   order by PRIORITY desc
+   for update skip locked;
+  result integer;
+begin
+  open c1;
+  fetch c1 into result;
+  close c1;
+  return result;
+end;
+/
+
+create or replace function next_job_medium_high(now timestamp)
+  return integer is
+  cursor c1 is
+    select JOB_ID from JOB
+    where PRIORITY != 0 and ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
+    order by PRIORITY desc
+    for update skip locked;
+  result integer;
+begin
+  open c1;
+  fetch c1 into result;
+  close c1;
+  return result;
+end;
+/
+"""
+        s1 = """create or replace function next_job_all(now timestamp)
+return integer is
+cursor c1 is
+select JOB_ID from JOB
+where ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
+order by PRIORITY desc
+for update skip locked;result integer;begin
+open c1;fetch c1 into result;close c1;return result;end;"""
+        s2 = """create or replace function next_job_medium_high(now timestamp)
+return integer is
+cursor c1 is
+select JOB_ID from JOB
+where PRIORITY != 0 and ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
+order by PRIORITY desc
+for update skip locked;result integer;begin
+open c1;fetch c1 into result;close c1;return result;end;"""
+
+        result = splitSQLString(plsql)
+        r1 = result.next()
+        self.assertEquals(r1, s1)
+        r2 = result.next()
+        self.assertEquals(r2, s2)
+        self.assertRaises(StopIteration, result.next)
+
+
     def test_actualSchemaUpgrade(self):
         """
         A real-world schema upgrade is split into the expected number of statements,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151007/e944e7bc/attachment.html>


More information about the calendarserver-changes mailing list