Commits

Kirill Simonov committed 54ca162

Fixed a problem with collapsing two frames with ORDER BY clauses.

Comments (0)

Files changed (9)

src/htsql/core/tr/stitch.py

     `with_weak` (Boolean)
         If set, include implicit flow ordering.
     """
-    return list(Arrange.__invoke__(flow, with_strong, with_weak))
+    order = []
+    duplicates = set()
+    for code, direction in Arrange.__invoke__(flow, with_strong, with_weak):
+        if code in duplicates:
+            continue
+        order.append((code, direction))
+        duplicates.add(code)
+    return order
 
 
 def spread(flow):

test/input/routine.yaml

 
   # Default address
   - start-ctl: &server-1 [server, *db, -q]
+    sleep: 1
   - py: GET-1
     code: |
       import time, urllib
 
   # Custom address
   - start-ctl: &server-2 [server, *db, --host, "127.0.0.1", --port, "8088", -q]
+    sleep: 1
   - py: GET-2
     code: |
       import time, urllib

test/input/translation.yaml

 
 - title: Known issues
   tests:
+  # A bug in collapsing two frames with ORDER BY clauses.
+  - uri: /school.sort(code-).limit(10)
   # Should produce a row for each record of `school`.
   - uri: /school.true()
   # If `school.campus` is treated as a link to a scalar class,

test/output/mssql.yaml

                                 ^^^^^^^^^^^^^^^^^^
       - id: known-issues
         tests:
+        - uri: /school.sort(code-).limit(10)
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          - [Vary, Accept]
+          body: |2
+             | school                                        |
+             +------+-------------------------------+--------+
+             | code | name                          | campus |
+            -+------+-------------------------------+--------+-
+             | sc   | School of Continuing Studies  |        |
+             | ph   | Public Honorariums            |        |
+             | ns   | School of Natural Sciences    | old    |
+             | mus  | School of Music & Dance       | south  |
+             | la   | School of Arts and Humanities | old    |
+             | eng  | School of Engineering         | north  |
+             | edu  | College of Education          | old    |
+             | bus  | School of Business            | south  |
+             | art  | School of Art & Design        | old    |
+
+             ----
+             /school.sort(code-).limit(10)
+             SELECT TOP 10
+                    [school].[code],
+                    [school].[name],
+                    [school].[campus]
+             FROM [ad].[school]
+             ORDER BY 1 DESC
         - uri: /school.true()
           status: 200 OK
           headers:
           - [Content-Type, text/plain; charset=UTF-8]
           - [Vary, Accept]
           body: |2
-             | department  |
-             +-------------+
-             | name        |
-            -+-------------+-
-             | Art History |
-             | Studio Art  |
+             | department |
+             +------------+
+             | name       |
+            -+------------+-
+             | Studio Art |
 
              ----
              /(school?code='art').department{name}
       id: embedding
       tests:
       - py-include: test/code/test_embedding.py
-        stdout: 'URI: /school{code, count(program), count(department)}
-
-          school(code=u''art'', [1]=3, [2]=1)
-
-          school(code=u''bus'', [1]=6, [2]=3)
-
-          school(code=u''edu'', [1]=7, [2]=2)
-
-          school(code=u''eng'', [1]=8, [2]=4)
-
-          school(code=u''la'', [1]=9, [2]=6)
-
-          school(code=u''mus'', [1]=0, [2]=4)
-
-          school(code=u''ns'', [1]=6, [2]=4)
-
-          school(code=u''ph'', [1]=1, [2]=0)
-
-          school(code=u''sc'', [1]=0, [2]=0)
-
+        stdout: |
+          URI: /school{code, count(program), count(department)}
+          school(code=u'art', [1]=3, [2]=1)
+          school(code=u'bus', [1]=6, [2]=3)
+          school(code=u'edu', [1]=7, [2]=2)
+          school(code=u'eng', [1]=8, [2]=4)
+          school(code=u'la', [1]=9, [2]=6)
+          school(code=u'mus', [1]=0, [2]=4)
+          school(code=u'ns', [1]=6, [2]=4)
+          school(code=u'ph', [1]=1, [2]=0)
+          school(code=u'sc', [1]=0, [2]=0)
 
           URI: /school{name, count(program)}?code=$school_code
-
-          $school_code: ''bus''
-
+          $school_code: 'bus'
           School of Business: 6
 
-
           URI: /school{name, num_prog:=count(program)}?num_prog>=$min_prog&num_prog<=$max_prog
-
           $min_prog: 6
-
           $max_prog: 8
-
           School of Business: 6
-
           College of Education: 7
-
           School of Engineering: 8
-
           School of Natural Sciences: 6
 
-
           URI: /school?campus==$campus
-
           $campus: None
-
-          school(code=u''ph'', name=u''Public Honorariums'', campus=None)
-
-          school(code=u''sc'', name=u''School of Continuing Studies'', campus=None)
-
+          school(code=u'ph', name=u'Public Honorariums', campus=None)
+          school(code=u'sc', name=u'School of Continuing Studies', campus=None)
 
           URI: /school?campus=$campus
-
-          $campus: [''north'', ''south'']
-
-          school(code=u''bus'', name=u''School of Business'', campus=u''south'')
-
-          school(code=u''eng'', name=u''School of Engineering'', campus=u''north'')
-
-          school(code=u''mus'', name=u''School of Music & Dance'', campus=u''south'')
-
-
-          URI: /{$untyped, $selector, $boolean, $integer, $float, $decimal, $date,
-          $time, $datetime}
-
-          $untyped: ''HTSQL''
-
-          $selector: [''HTTP'', ''SQL'']
-
+          $campus: ['north', 'south']
+          school(code=u'bus', name=u'School of Business', campus=u'south')
+          school(code=u'eng', name=u'School of Engineering', campus=u'north')
+          school(code=u'mus', name=u'School of Music & Dance', campus=u'south')
+
+          URI: /{$untyped, $selector, $boolean, $integer, $float, $decimal, $date, $time, $datetime}
+          $untyped: 'HTSQL'
+          $selector: ['HTTP', 'SQL']
           $boolean: True
-
           $integer: 3571
-
           $float: -0.57721
-
-          $decimal: Decimal(''0.875'')
-
+          $decimal: Decimal('0.875')
           $date: datetime.date(2010, 4, 15)
-
           $time: datetime.time(20, 3)
-
           $datetime: datetime.datetime(2010, 4, 15, 20, 3)
-
-          Record([0]=u''HTSQL'', [1]=Record([0]=u''HTTP'', [1]=u''SQL''), [2]=True,
-          [3]=3571, [4]=-0.57721, [5]=Decimal(''0.875''), [6]=datetime.date(2010,
-          4, 15), [7]=datetime.time(20, 3), [8]=datetime.datetime(2010, 4, 15, 20,
-          3))
-
+          Record([0]=u'HTSQL', [1]=Record([0]=u'HTTP', [1]=u'SQL'), [2]=True, [3]=3571, [4]=-0.57721, [5]=Decimal('0.875'), [6]=datetime.date(2010, 4, 15), [7]=datetime.time(20, 3), [8]=datetime.datetime(2010, 4, 15, 20, 3))
 
           URI: /meta(/link?table.name=$table_name)
-
-          $table_name: ''school''
-
-          link(table_name=u''school'', name=u''department'', is_singular=False, target_name=u''department'',
-          reverse_name=u''school'')
-
-          link(table_name=u''school'', name=u''program'', is_singular=False, target_name=u''program'',
-          reverse_name=u''school'')
-
+          $table_name: 'school'
+          link(table_name=u'school', name=u'department', is_singular=False, target_name=u'department', reverse_name=u'school')
+          link(table_name=u'school', name=u'program', is_singular=False, target_name=u'program', reverse_name=u'school')
 
           URI: /school
-
-          school(code=u''art'', name=u''School of Art & Design'', campus=u''old'')
-
-          school(code=u''bus'', name=u''School of Business'', campus=u''south'')
-
-          school(code=u''edu'', name=u''College of Education'', campus=u''old'')
-
-'
+          school(code=u'art', name=u'School of Art & Design', campus=u'old')
+          school(code=u'bus', name=u'School of Business', campus=u'south')
+          school(code=u'edu', name=u'College of Education', campus=u'old')

test/output/mysql.yaml

                                 ^^^^^^^^^^^^^^^^^^
       - id: known-issues
         tests:
+        - uri: /school.sort(code-).limit(10)
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          - [Vary, Accept]
+          body: |2
+             | school                                        |
+             +------+-------------------------------+--------+
+             | code | name                          | campus |
+            -+------+-------------------------------+--------+-
+             | sc   | School of Continuing Studies  |        |
+             | ph   | Public Honorariums            |        |
+             | ns   | School of Natural Sciences    | old    |
+             | mus  | School of Music & Dance       | south  |
+             | la   | School of Arts and Humanities | old    |
+             | eng  | School of Engineering         | north  |
+             | edu  | College of Education          | old    |
+             | bus  | School of Business            | south  |
+             | art  | School of Art & Design        | old    |
+
+             ----
+             /school.sort(code-).limit(10)
+             SELECT `school`.`code`,
+                    `school`.`name`,
+                    `school`.`campus`
+             FROM `school`
+             ORDER BY 1 DESC
+             LIMIT 10
         - uri: /school.true()
           status: 200 OK
           headers:
           - [Content-Type, text/plain; charset=UTF-8]
           - [Vary, Accept]
           body: |2
-             | department  |
-             +-------------+
-             | name        |
-            -+-------------+-
-             | Art History |
-             | Studio Art  |
+             | department |
+             +------------+
+             | name       |
+            -+------------+-
+             | Studio Art |
 
              ----
              /(school?code='art').department{name}
       id: embedding
       tests:
       - py-include: test/code/test_embedding.py
-        stdout: 'URI: /school{code, count(program), count(department)}
-
-          school(code=u''art'', [1]=3L, [2]=1L)
-
-          school(code=u''bus'', [1]=6L, [2]=3L)
-
-          school(code=u''edu'', [1]=7L, [2]=2L)
-
-          school(code=u''eng'', [1]=8L, [2]=4L)
-
-          school(code=u''la'', [1]=9L, [2]=6L)
-
-          school(code=u''mus'', [1]=0L, [2]=4L)
-
-          school(code=u''ns'', [1]=6L, [2]=4L)
-
-          school(code=u''ph'', [1]=1L, [2]=0L)
-
-          school(code=u''sc'', [1]=0L, [2]=0L)
-
+        stdout: |
+          URI: /school{code, count(program), count(department)}
+          school(code=u'art', [1]=3L, [2]=1L)
+          school(code=u'bus', [1]=6L, [2]=3L)
+          school(code=u'edu', [1]=7L, [2]=2L)
+          school(code=u'eng', [1]=8L, [2]=4L)
+          school(code=u'la', [1]=9L, [2]=6L)
+          school(code=u'mus', [1]=0L, [2]=4L)
+          school(code=u'ns', [1]=6L, [2]=4L)
+          school(code=u'ph', [1]=1L, [2]=0L)
+          school(code=u'sc', [1]=0L, [2]=0L)
 
           URI: /school{name, count(program)}?code=$school_code
-
-          $school_code: ''bus''
-
+          $school_code: 'bus'
           School of Business: 6
 
-
           URI: /school{name, num_prog:=count(program)}?num_prog>=$min_prog&num_prog<=$max_prog
-
           $min_prog: 6
-
           $max_prog: 8
-
           School of Business: 6
-
           College of Education: 7
-
           School of Engineering: 8
-
           School of Natural Sciences: 6
 
-
           URI: /school?campus==$campus
-
           $campus: None
-
-          school(code=u''ph'', name=u''Public Honorariums'', campus=None)
-
-          school(code=u''sc'', name=u''School of Continuing Studies'', campus=None)
-
+          school(code=u'ph', name=u'Public Honorariums', campus=None)
+          school(code=u'sc', name=u'School of Continuing Studies', campus=None)
 
           URI: /school?campus=$campus
-
-          $campus: [''north'', ''south'']
-
-          school(code=u''bus'', name=u''School of Business'', campus=u''south'')
-
-          school(code=u''eng'', name=u''School of Engineering'', campus=u''north'')
-
-          school(code=u''mus'', name=u''School of Music & Dance'', campus=u''south'')
-
-
-          URI: /{$untyped, $selector, $boolean, $integer, $float, $decimal, $date,
-          $time, $datetime}
-
-          $untyped: ''HTSQL''
-
-          $selector: [''HTTP'', ''SQL'']
-
+          $campus: ['north', 'south']
+          school(code=u'bus', name=u'School of Business', campus=u'south')
+          school(code=u'eng', name=u'School of Engineering', campus=u'north')
+          school(code=u'mus', name=u'School of Music & Dance', campus=u'south')
+
+          URI: /{$untyped, $selector, $boolean, $integer, $float, $decimal, $date, $time, $datetime}
+          $untyped: 'HTSQL'
+          $selector: ['HTTP', 'SQL']
           $boolean: True
-
           $integer: 3571
-
           $float: -0.57721
-
-          $decimal: Decimal(''0.875'')
-
+          $decimal: Decimal('0.875')
           $date: datetime.date(2010, 4, 15)
-
           $time: datetime.time(20, 3)
-
           $datetime: datetime.datetime(2010, 4, 15, 20, 3)
-
-          Record([0]=u''HTSQL'', [1]=Record([0]=u''HTTP'', [1]=u''SQL''), [2]=True,
-          [3]=3571L, [4]=-0.57721, [5]=Decimal(''0.875''), [6]=datetime.date(2010,
-          4, 15), [7]=datetime.time(20, 3), [8]=datetime.datetime(2010, 4, 15, 20,
-          3))
-
+          Record([0]=u'HTSQL', [1]=Record([0]=u'HTTP', [1]=u'SQL'), [2]=True, [3]=3571L, [4]=-0.57721, [5]=Decimal('0.875'), [6]=datetime.date(2010, 4, 15), [7]=datetime.time(20, 3), [8]=datetime.datetime(2010, 4, 15, 20, 3))
 
           URI: /meta(/link?table.name=$table_name)
-
-          $table_name: ''school''
-
-          link(table_name=u''school'', name=u''department'', is_singular=False, target_name=u''department'',
-          reverse_name=u''school'')
-
-          link(table_name=u''school'', name=u''program'', is_singular=False, target_name=u''program'',
-          reverse_name=u''school'')
-
+          $table_name: 'school'
+          link(table_name=u'school', name=u'department', is_singular=False, target_name=u'department', reverse_name=u'school')
+          link(table_name=u'school', name=u'program', is_singular=False, target_name=u'program', reverse_name=u'school')
 
           URI: /school
-
-          school(code=u''art'', name=u''School of Art & Design'', campus=u''old'')
-
-          school(code=u''bus'', name=u''School of Business'', campus=u''south'')
-
-          school(code=u''edu'', name=u''College of Education'', campus=u''old'')
-
-'
+          school(code=u'art', name=u'School of Art & Design', campus=u'old')
+          school(code=u'bus', name=u'School of Business', campus=u'south')
+          school(code=u'edu', name=u'College of Education', campus=u'old')

test/output/oracle.yaml

                                 ^^^^^^^^^^^^^^^^^^
       - id: known-issues
         tests:
+        - uri: /school.sort(code-).limit(10)
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          - [Vary, Accept]
+          body: |2
+             | school                                        |
+             +------+-------------------------------+--------+
+             | code | name                          | campus |
+            -+------+-------------------------------+--------+-
+             | sc   | School of Continuing Studies  |        |
+             | ph   | Public Honorariums            |        |
+             | ns   | School of Natural Sciences    | old    |
+             | mus  | School of Music & Dance       | south  |
+             | la   | School of Arts and Humanities | old    |
+             | eng  | School of Engineering         | north  |
+             | edu  | College of Education          | old    |
+             | bus  | School of Business            | south  |
+             | art  | School of Art & Design        | old    |
+
+             ----
+             /school.sort(code-).limit(10)
+             SELECT "SCHOOL"."CODE",
+                    "SCHOOL"."NAME",
+                    "SCHOOL"."CAMPUS"
+             FROM (SELECT "SCHOOL"."CODE",
+                          "SCHOOL"."NAME",
+                          "SCHOOL"."CAMPUS"
+                   FROM (SELECT "SCHOOL"."CODE",
+                                "SCHOOL"."NAME",
+                                "SCHOOL"."CAMPUS"
+                         FROM "SCHOOL"
+                         ORDER BY 1 DESC) "SCHOOL"
+                   WHERE (ROWNUM < 11)) "SCHOOL"
+             ORDER BY 1 DESC
         - uri: /school.true()
           status: 200 OK
           headers:
           - [Content-Type, text/plain; charset=UTF-8]
           - [Vary, Accept]
           body: |2
-             | department  |
-             +-------------+
-             | name        |
-            -+-------------+-
-             | Art History |
-             | Studio Art  |
+             | department |
+             +------------+
+             | name       |
+            -+------------+-
+             | Studio Art |
 
              ----
              /(school?code='art').department{name}

test/output/pgsql.yaml

                                 ^^^^^^^^^^^^^^^^^^
       - id: known-issues
         tests:
+        - uri: /school.sort(code-).limit(10)
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          - [Vary, Accept]
+          body: |2
+             | school                                        |
+             +------+-------------------------------+--------+
+             | code | name                          | campus |
+            -+------+-------------------------------+--------+-
+             | sc   | School of Continuing Studies  |        |
+             | ph   | Public Honorariums            |        |
+             | ns   | School of Natural Sciences    | old    |
+             | mus  | School of Music & Dance       | south  |
+             | la   | School of Arts and Humanities | old    |
+             | eng  | School of Engineering         | north  |
+             | edu  | College of Education          | old    |
+             | bus  | School of Business            | south  |
+             | art  | School of Art & Design        | old    |
+
+             ----
+             /school.sort(code-).limit(10)
+             SELECT "school"."code",
+                    "school"."name",
+                    "school"."campus"
+             FROM "ad"."school"
+             ORDER BY 1 DESC
+             LIMIT 10
         - uri: /school.true()
           status: 200 OK
           headers:
           - [Content-Type, text/plain; charset=UTF-8]
           - [Vary, Accept]
           body: |2
-             | department  |
-             +-------------+
-             | name        |
-            -+-------------+-
-             | Art History |
-             | Studio Art  |
+             | department |
+             +------------+
+             | name       |
+            -+------------+-
+             | Studio Art |
 
              ----
              /(school?code='art').department{name}
       id: embedding
       tests:
       - py-include: test/code/test_embedding.py
-        stdout: 'URI: /school{code, count(program), count(department)}
-
-          school(code=u''art'', [1]=3L, [2]=1L)
-
-          school(code=u''bus'', [1]=6L, [2]=3L)
-
-          school(code=u''edu'', [1]=7L, [2]=2L)
-
-          school(code=u''eng'', [1]=8L, [2]=4L)
-
-          school(code=u''la'', [1]=9L, [2]=6L)
-
-          school(code=u''mus'', [1]=0L, [2]=4L)
-
-          school(code=u''ns'', [1]=6L, [2]=4L)
-
-          school(code=u''ph'', [1]=1L, [2]=0L)
-
-          school(code=u''sc'', [1]=0L, [2]=0L)
-
+        stdout: |
+          URI: /school{code, count(program), count(department)}
+          school(code=u'art', [1]=3L, [2]=1L)
+          school(code=u'bus', [1]=6L, [2]=3L)
+          school(code=u'edu', [1]=7L, [2]=2L)
+          school(code=u'eng', [1]=8L, [2]=4L)
+          school(code=u'la', [1]=9L, [2]=6L)
+          school(code=u'mus', [1]=0L, [2]=4L)
+          school(code=u'ns', [1]=6L, [2]=4L)
+          school(code=u'ph', [1]=1L, [2]=0L)
+          school(code=u'sc', [1]=0L, [2]=0L)
 
           URI: /school{name, count(program)}?code=$school_code
-
-          $school_code: ''bus''
-
+          $school_code: 'bus'
           School of Business: 6
 
-
           URI: /school{name, num_prog:=count(program)}?num_prog>=$min_prog&num_prog<=$max_prog
-
           $min_prog: 6
-
           $max_prog: 8
-
           School of Business: 6
-
           College of Education: 7
-
           School of Engineering: 8
-
           School of Natural Sciences: 6
 
-
           URI: /school?campus==$campus
-
           $campus: None
-
-          school(code=u''ph'', name=u''Public Honorariums'', campus=None)
-
-          school(code=u''sc'', name=u''School of Continuing Studies'', campus=None)
-
+          school(code=u'ph', name=u'Public Honorariums', campus=None)
+          school(code=u'sc', name=u'School of Continuing Studies', campus=None)
 
           URI: /school?campus=$campus
-
-          $campus: [''north'', ''south'']
-
-          school(code=u''bus'', name=u''School of Business'', campus=u''south'')
-
-          school(code=u''eng'', name=u''School of Engineering'', campus=u''north'')
-
-          school(code=u''mus'', name=u''School of Music & Dance'', campus=u''south'')
-
-
-          URI: /{$untyped, $selector, $boolean, $integer, $float, $decimal, $date,
-          $time, $datetime}
-
-          $untyped: ''HTSQL''
-
-          $selector: [''HTTP'', ''SQL'']
-
+          $campus: ['north', 'south']
+          school(code=u'bus', name=u'School of Business', campus=u'south')
+          school(code=u'eng', name=u'School of Engineering', campus=u'north')
+          school(code=u'mus', name=u'School of Music & Dance', campus=u'south')
+
+          URI: /{$untyped, $selector, $boolean, $integer, $float, $decimal, $date, $time, $datetime}
+          $untyped: 'HTSQL'
+          $selector: ['HTTP', 'SQL']
           $boolean: True
-
           $integer: 3571
-
           $float: -0.57721
-
-          $decimal: Decimal(''0.875'')
-
+          $decimal: Decimal('0.875')
           $date: datetime.date(2010, 4, 15)
-
           $time: datetime.time(20, 3)
-
           $datetime: datetime.datetime(2010, 4, 15, 20, 3)
-
-          Record([0]=u''HTSQL'', [1]=Record([0]=u''HTTP'', [1]=u''SQL''), [2]=True,
-          [3]=3571, [4]=-0.57721, [5]=Decimal(''0.875''), [6]=datetime.date(2010,
-          4, 15), [7]=datetime.time(20, 3), [8]=datetime.datetime(2010, 4, 15, 20,
-          3))
-
+          Record([0]=u'HTSQL', [1]=Record([0]=u'HTTP', [1]=u'SQL'), [2]=True, [3]=3571, [4]=-0.57721, [5]=Decimal('0.875'), [6]=datetime.date(2010, 4, 15), [7]=datetime.time(20, 3), [8]=datetime.datetime(2010, 4, 15, 20, 3))
 
           URI: /meta(/link?table.name=$table_name)
-
-          $table_name: ''school''
-
-          link(table_name=u''school'', name=u''department'', is_singular=False, target_name=u''department'',
-          reverse_name=u''school'')
-
-          link(table_name=u''school'', name=u''program'', is_singular=False, target_name=u''program'',
-          reverse_name=u''school'')
-
+          $table_name: 'school'
+          link(table_name=u'school', name=u'department', is_singular=False, target_name=u'department', reverse_name=u'school')
+          link(table_name=u'school', name=u'program', is_singular=False, target_name=u'program', reverse_name=u'school')
 
           URI: /school
-
-          school(code=u''art'', name=u''School of Art & Design'', campus=u''old'')
-
-          school(code=u''bus'', name=u''School of Business'', campus=u''south'')
-
-          school(code=u''edu'', name=u''College of Education'', campus=u''old'')
-
-'
+          school(code=u'art', name=u'School of Art & Design', campus=u'old')
+          school(code=u'bus', name=u'School of Business', campus=u'south')
+          school(code=u'edu', name=u'College of Education', campus=u'old')

test/output/routine.yaml

 
     exit: 0
   - py: GET-1
-    stdout: |+
-      File not found.
+    stdout: |2+
+       | count(school) |
+      -+---------------+-
+       |             9 |
+
 
   - end-ctl: [server, 'sqlite:build/regress/sqlite/htsql_demo.sqlite', -q]
     stdout: ''

test/output/sqlite.yaml

                                 ^^^^^^^^^^^^^^^^^^
       - id: known-issues
         tests:
+        - uri: /school.sort(code-).limit(10)
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          - [Vary, Accept]
+          body: |2
+             | school                                        |
+             +------+-------------------------------+--------+
+             | code | name                          | campus |
+            -+------+-------------------------------+--------+-
+             | sc   | School of Continuing Studies  |        |
+             | ph   | Public Honorariums            |        |
+             | ns   | School of Natural Sciences    | old    |
+             | mus  | School of Music & Dance       | south  |
+             | la   | School of Arts and Humanities | old    |
+             | eng  | School of Engineering         | north  |
+             | edu  | College of Education          | old    |
+             | bus  | School of Business            | south  |
+             | art  | School of Art & Design        | old    |
+
+             ----
+             /school.sort(code-).limit(10)
+             SELECT "school"."code",
+                    "school"."name",
+                    "school"."campus"
+             FROM "school"
+             ORDER BY 1 DESC
+             LIMIT 10
         - uri: /school.true()
           status: 200 OK
           headers:
           - [Content-Type, text/plain; charset=UTF-8]
           - [Vary, Accept]
           body: |2
-             | department  |
-             +-------------+
-             | name        |
-            -+-------------+-
-             | Art History |
-             | Studio Art  |
+             | department |
+             +------------+
+             | name       |
+            -+------------+-
+             | Studio Art |
 
              ----
              /(school?code='art').department{name}