Commits

Kirill Simonov committed 5ac6419

fetch(): support for scalar queries.

Comments (0)

Files changed (12)

src/htsql/core/tr/assemble.py

 from ..adapter import Adapter, adapt, adapt_many
 from ..domain import BooleanDomain, UntypedDomain
 from .coerce import coerce
+from .syntax import WeakSegmentSyntax
 from .flow import (Code, SegmentCode, LiteralCode, FormulaCode, CastCode,
                    RecordCode, IdentityCode, AnnihilatorCode, CorrelationCode,
                    Unit, ColumnUnit, CompoundUnit)
             self.state.push_segment(self.code)
             compose_code = self.state.decompose(self.code.code)
             self.state.pop_segment()
-            def compose_root_segment(row, stream, compose_code=compose_code):
-                items = []
-                for row in stream:
-                    items.append(compose_code(row, stream))
-                return items
-            return compose_root_segment
+            is_single = (isinstance(self.code.syntax, WeakSegmentSyntax))
+            if not is_single:
+                def compose_root_segment(row, stream,
+                                         compose_code=compose_code):
+                    items = []
+                    for row in stream:
+                        items.append(compose_code(row, stream))
+                    return items
+                return compose_root_segment
+            else:
+                def compose_root_value(row, stream,
+                                       compose_code=compose_code):
+                    items = []
+                    for row in stream:
+                        items.append(compose_code(row, stream))
+                    assert len(items) <= 1
+                    if items:
+                        return items[0]
+                    else:
+                        return None
+                return compose_root_value
         else:
             key_stencil = self.state.get_key_stencil()
             self.state.push_segment(self.code)

src/htsql/core/tr/bind.py

         IdentityDomain, VoidDomain)
 from ..classify import normalize
 from .error import BindError
-from .syntax import (Syntax, QuerySyntax, SegmentSyntax, SelectorSyntax,
-        ApplicationSyntax, FunctionSyntax, MappingSyntax, OperatorSyntax,
-        QuotientSyntax, SieveSyntax, LinkSyntax, HomeSyntax, AssignmentSyntax,
-        SpecifierSyntax, LocatorSyntax, LocationSyntax, GroupSyntax,
-        IdentifierSyntax, WildcardSyntax, ReferenceSyntax, ComplementSyntax,
-        StringSyntax, NumberSyntax)
+from .syntax import (Syntax, QuerySyntax, WeakSegmentSyntax, SegmentSyntax,
+        SelectorSyntax, ApplicationSyntax, FunctionSyntax, MappingSyntax,
+        OperatorSyntax, QuotientSyntax, SieveSyntax, LinkSyntax, HomeSyntax,
+        AssignmentSyntax, SpecifierSyntax, LocatorSyntax, LocationSyntax,
+        GroupSyntax, IdentifierSyntax, WildcardSyntax, ReferenceSyntax,
+        ComplementSyntax, StringSyntax, NumberSyntax)
 from .binding import (Binding, WrappingBinding, QueryBinding, SegmentBinding,
         RootBinding, HomeBinding, FreeTableBinding, AttachedTableBinding,
         ColumnBinding, QuotientBinding, KernelBinding, ComplementBinding,
             seed = self.state.scope
         if lookup_command(seed) is not None:
             return seed
+        if (isinstance(self.syntax, WeakSegmentSyntax) and
+                isinstance(seed, SegmentBinding)):
+            return seed
         seed = Select.__invoke__(seed, self.state)
-        domain = ListDomain(seed.domain)
+        if isinstance(self.syntax, WeakSegmentSyntax):
+            domain = seed.domain
+        else:
+            domain = ListDomain(seed.domain)
         return SegmentBinding(self.state.scope, seed, domain,
                               self.syntax)
 

src/htsql/core/tr/encode.py

         OpaqueDomain)
 from .error import EncodeError
 from .coerce import coerce
+from .syntax import WeakSegmentSyntax
 from .binding import (Binding, QueryBinding, SegmentBinding, WrappingBinding,
         SelectionBinding, HomeBinding, RootBinding, FreeTableBinding,
         AttachedTableBinding, ColumnBinding, QuotientBinding, KernelBinding,
             filter = FormulaCode(IsNullSig(-1), coerce(BooleanDomain()),
                                  code.binding, op=code)
             flow = FilteredFlow(flow, filter, flow.binding)
+        if isinstance(self.binding.syntax, WeakSegmentSyntax):
+            if not root.spans(flow):
+                raise EncodeError("a singular expression is expected",
+                                  self.binding.mark)
         return SegmentCode(root, flow, code, self.binding)
 
 

src/htsql/core/tr/fn/bind.py

 from ...domain import (Domain, UntypedDomain, BooleanDomain, StringDomain,
         IntegerDomain, DecimalDomain, FloatDomain, DateDomain, TimeDomain,
         DateTimeDomain, EnumDomain, ListDomain, RecordDomain)
-from ..syntax import (NumberSyntax, StringSyntax, IdentifierSyntax,
-        SpecifierSyntax, ApplicationSyntax, OperatorSyntax, GroupSyntax)
+from ..syntax import (WeakSegmentSyntax, NumberSyntax, StringSyntax,
+        IdentifierSyntax, SpecifierSyntax, ApplicationSyntax, OperatorSyntax,
+        GroupSyntax)
 from ..binding import (LiteralBinding, SortBinding, SieveBinding,
         FormulaBinding, CastBinding, ImplicitCastBinding, WrappingBinding,
         TitleBinding, DirectionBinding, QuotientBinding, AssignmentBinding,
     call('fetch')
 
     def expand(self, op):
+        op = WeakSegmentSyntax(op, op.mark)
         op = self.state.bind(op)
         if not isinstance(op, SegmentBinding):
             raise BindError("function '%s' expects a segment argument"

src/htsql/core/tr/plan.py

 
 class Statement(Printable):
 
-    def __init__(self, sql, domains, substatements, placeholders=None):
+    def __init__(self, sql, domains, substatements,
+                 placeholders=None, is_single=False):
         assert isinstance(sql, unicode)
         assert isinstance(domains, listof(Domain))
         assert isinstance(substatements, listof(Statement))
         self.domains = domains
         self.substatements = substatements
         self.placeholders = placeholders
+        self.is_single = is_single
 
 
 class Plan(Printable):

src/htsql/core/tr/syntax.py

             return u'/%s' % self.branch
 
 
+class WeakSegmentSyntax(SegmentSyntax):
+
+    def __unicode__(self):
+        return unicode(self.branch)
+
+
 class SelectorSyntax(Syntax):
     """
     Represents a selector expression.

test/input/format.yaml

   - uri: /(/(/(/(/true))))/:html
   - uri: /(/(/(/(/true))))/:txt
 
+- title: Scalar Data
+  tests:
+  - uri: /fetch(null)/:raw
+  - uri: /fetch(null)/:json
+  - uri: /fetch(null)/:csv
+  - uri: /fetch(null)/:tsv
+  - uri: /fetch(null)/:xml
+  - uri: /fetch(null)/:html
+  - uri: /fetch(null)/:txt
+  - uri: /fetch({})/:raw
+  - uri: /fetch({})/:json
+  - uri: /fetch({})/:csv
+  - uri: /fetch({})/:tsv
+  - uri: /fetch({})/:xml
+  - uri: /fetch({})/:html
+    skip: true # shows the welcome page
+  - uri: /fetch({})/:txt
+  - uri: /fetch(count(school))/:raw
+  - uri: /fetch(count(school))/:json
+  - uri: /fetch(count(school))/:csv
+  - uri: /fetch(count(school))/:tsv
+  - uri: /fetch(count(school))/:xml
+  - uri: /fetch(count(school))/:html
+  - uri: /fetch(count(school))/:txt
+  - uri: /fetch(school[art])/:raw
+  - uri: /fetch(school[art])/:json
+  - uri: /fetch(school[art])/:csv
+  - uri: /fetch(school[art])/:tsv
+  - uri: /fetch(school[art])/:xml
+  - uri: /fetch(school[art])/:html
+  - uri: /fetch(school[art])/:txt
+  - uri: /fetch(school[none])/:raw
+  - uri: /fetch(school[none])/:json
+  - uri: /fetch(school[none])/:csv
+  - uri: /fetch(school[none])/:tsv
+  - uri: /fetch(school[none])/:xml
+  - uri: /fetch(school[none])/:html
+    skip: true # no rows are displayed
+  - uri: /fetch(school[none])/:txt
+  - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:raw
+  - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:json
+  - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:csv
+  - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:tsv
+  - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:xml
+  - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:html
+  - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:txt
+
 - title: Commands
   tests:
   - uri: /school/:fetch

test/output/mssql.yaml

 
                      SELECT 1
                      WHERE (1 <> 0)
+      - id: scalar-data
+        tests:
+        - uri: /fetch(null)/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="null.js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "untyped"
+                },
+                "header": "null",
+                "syntax": "null",
+                "tag": "null"
+              }
+            }
+        - uri: /fetch(null)/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="null.js"]
+          body: |
+            {}
+        - uri: /fetch(null)/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="null.csv"]
+          body: "null\r\n\"\"\r\n"
+        - uri: /fetch(null)/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="null.tsv"]
+          body: "null\r\n\"\"\r\n"
+        - uri: /fetch(null)/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="null.xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml" />
+        - uri: /fetch(null)/:html
+          status: 200 OK
+          headers:
+          - [Content-Type, text/html; charset=UTF-8]
+          body: |
+            <!DOCTYPE html>
+            <html>
+            <head>
+            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+            <title>null</title>
+            <style type="text/css">
+            table.htsql-output { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; margin: 1em auto; color: #000000; background-color: #ffffff; border-collapse: collapse; border: 1px double #f2f2f2; -moz-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); -webkit-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); box-shadow: 1px 1px 3px rgba(0,0,0,0.25) }
+            table.htsql-output > thead { background-color: #f2f2f2; border-bottom: 1px solid #1a1a1a }
+            table.htsql-output > thead > tr > th { font-weight: bold; padding: 0.2em 0.5em; text-align: center; vertical-align: bottom; overflow: hidden; word-wrap: break-word; border-top: 1px solid #999999; border-left: 1px solid #999999 }
+            table.htsql-output > thead > tr > th.htsql-empty-header:after { content: "\A0" }
+            table.htsql-output > tbody > tr.htsql-odd-row { background-color: #ffffff }
+            table.htsql-output > tbody > tr.htsql-even-row { background-color: #f2f2f2 }
+            table.htsql-output > tbody > tr:hover { color: #ffffff; background-color: #333333 }
+            table.htsql-output > tbody > tr > td { padding: 0.2em 0.5em; vertical-align: baseline; overflow: hidden; word-wrap: break-word; border-left: 1px solid #999999; border-right: 1px solid #999999 }
+            table.htsql-output > tbody > tr > td.htsql-integer-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-decimal-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-float-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-null-value:after { content: "\A0" }
+            table.htsql-output > tbody > tr > td.htsql-empty-value { color: #999999 }
+            table.htsql-output > tbody > tr > td.htsql-empty-value:after { content: "\2B1A" }
+            table.htsql-output > tbody > tr > td.htsql-false-value { font-style: italic }
+            table.htsql-output > tbody > tr > td.htsql-null-record-value { border-left-style: dashed; border-right-style: dashed }
+            table.htsql-output > tbody > tr > td.htsql-section { border-top: 1px dotted #999999 }
+            table.htsql-output > tbody > tr > td.htsql-index { font-size: 90%; font-weight: bold; text-align: right; width: 0; color: #999999; border-left-style: solid; border-right-color: #1a1a1a; -moz-user-select: none; -webkit-user-select: none; user-select: none }
+            div.htsql-welcome { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; text-align: center; margin: 1em auto; color: #000000; background-color: #ffffff }
+            div.htsql-welcome > h1 { font-size: 200%; font-weight: bold; margin: 1px 0 0 }
+            div.htsql-welcome > p { margin: 1px 0 0 }
+            </style>
+            </head>
+            <body>
+            <table class="htsql-output" summary="null">
+            <thead>
+            <tr><th>null</th></tr>
+            </thead>
+            <tbody>
+            <tr class="htsql-odd-row"><td class="htsql-untyped-type htsql-null-value"></td></tr>
+            </tbody>
+            </table>
+            </body>
+            </html>
+        - uri: /fetch(null)/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | null |
+            -+------+-
+             |      |
+
+             ----
+             null
+             SELECT 1
+             WHERE (0 <> 0)
+        - uri: /fetch({})/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="_.js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "record",
+                  "fields": []
+                },
+                "path": "",
+                "syntax": "{}"
+              },
+              "data": []
+            }
+        - uri: /fetch({})/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="_.js"]
+          body: |
+            {
+              "0": {}
+            }
+        - uri: /fetch({})/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="_.csv"]
+          body: ''
+        - uri: /fetch({})/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="_.tsv"]
+          body: ''
+        - uri: /fetch({})/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="_.xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml">
+              <_ />
+            </htsql:result>
+        - uri: /fetch({})/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: ''
+        - uri: /fetch(count(school))/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="count(school).js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "integer"
+                },
+                "header": "count(school)",
+                "syntax": "count(school)"
+              },
+              "data": 9
+            }
+        - uri: /fetch(count(school))/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="count(school).js"]
+          body: |
+            {
+              "0": 9
+            }
+        - uri: /fetch(count(school))/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="count(school).csv"]
+          body: "count(school)\r\n9\r\n"
+        - uri: /fetch(count(school))/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="count(school).tsv"]
+          body: "count(school)\r\n9\r\n"
+        - uri: /fetch(count(school))/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="count(school).xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml">
+              <_>9</_>
+            </htsql:result>
+        - uri: /fetch(count(school))/:html
+          status: 200 OK
+          headers:
+          - [Content-Type, text/html; charset=UTF-8]
+          body: |
+            <!DOCTYPE html>
+            <html>
+            <head>
+            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+            <title>count(school)</title>
+            <style type="text/css">
+            table.htsql-output { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; margin: 1em auto; color: #000000; background-color: #ffffff; border-collapse: collapse; border: 1px double #f2f2f2; -moz-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); -webkit-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); box-shadow: 1px 1px 3px rgba(0,0,0,0.25) }
+            table.htsql-output > thead { background-color: #f2f2f2; border-bottom: 1px solid #1a1a1a }
+            table.htsql-output > thead > tr > th { font-weight: bold; padding: 0.2em 0.5em; text-align: center; vertical-align: bottom; overflow: hidden; word-wrap: break-word; border-top: 1px solid #999999; border-left: 1px solid #999999 }
+            table.htsql-output > thead > tr > th.htsql-empty-header:after { content: "\A0" }
+            table.htsql-output > tbody > tr.htsql-odd-row { background-color: #ffffff }
+            table.htsql-output > tbody > tr.htsql-even-row { background-color: #f2f2f2 }
+            table.htsql-output > tbody > tr:hover { color: #ffffff; background-color: #333333 }
+            table.htsql-output > tbody > tr > td { padding: 0.2em 0.5em; vertical-align: baseline; overflow: hidden; word-wrap: break-word; border-left: 1px solid #999999; border-right: 1px solid #999999 }
+            table.htsql-output > tbody > tr > td.htsql-integer-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-decimal-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-float-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-null-value:after { content: "\A0" }
+            table.htsql-output > tbody > tr > td.htsql-empty-value { color: #999999 }
+            table.htsql-output > tbody > tr > td.htsql-empty-value:after { content: "\2B1A" }
+            table.htsql-output > tbody > tr > td.htsql-false-value { font-style: italic }
+            table.htsql-output > tbody > tr > td.htsql-null-record-value { border-left-style: dashed; border-right-style: dashed }
+            table.htsql-output > tbody > tr > td.htsql-section { border-top: 1px dotted #999999 }
+            table.htsql-output > tbody > tr > td.htsql-index { font-size: 90%; font-weight: bold; text-align: right; width: 0; color: #999999; border-left-style: solid; border-right-color: #1a1a1a; -moz-user-select: none; -webkit-user-select: none; user-select: none }
+            div.htsql-welcome { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; text-align: center; margin: 1em auto; color: #000000; background-color: #ffffff }
+            div.htsql-welcome > h1 { font-size: 200%; font-weight: bold; margin: 1px 0 0 }
+            div.htsql-welcome > p { margin: 1px 0 0 }
+            </style>
+            </head>
+            <body>
+            <table class="htsql-output" summary="count(school)">
+            <thead>
+            <tr><th>count(school)</th></tr>
+            </thead>
+            <tbody>
+            <tr class="htsql-odd-row"><td class="htsql-integer-type">9</td></tr>
+            </tbody>
+            </table>
+            </body>
+            </html>
+        - uri: /fetch(count(school))/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | count(school) |
+            -+---------------+-
+             |             9 |
+
+             ----
+             count(school)
+             SELECT [school].[count]
+             FROM (SELECT COUNT(1) AS [count]
+                   FROM [ad].[school]) AS [school]
+             WHERE ([school].[count] IS NOT NULL)
+        - uri: /fetch(school[art])/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="school.js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "record",
+                  "fields": [
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "code",
+                      "syntax": "code",
+                      "tag": "code"
+                    },
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "name",
+                      "syntax": "name",
+                      "tag": "name"
+                    },
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "campus",
+                      "syntax": "campus",
+                      "tag": "campus"
+                    }
+                  ]
+                },
+                "header": "school",
+                "syntax": "school[art]",
+                "tag": "school"
+              },
+              "data": [
+                "art",
+                "School of Art & Design",
+                "old"
+              ]
+            }
+        - uri: /fetch(school[art])/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="school.js"]
+          body: |
+            {
+              "school": {
+                "code": "art",
+                "name": "School of Art & Design",
+                "campus": "old"
+              }
+            }
+        - uri: /fetch(school[art])/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="school.csv"]
+          body: "code,name,campus\r\nart,School of Art & Design,old\r\n"
+        - uri: /fetch(school[art])/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="school.tsv"]
+          body: "code\tname\tcampus\r\nart\tSchool of Art & Design\told\r\n"
+        - uri: /fetch(school[art])/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="school.xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml">
+              <school>
+                <code>art</code>
+                <name>School of Art &amp; Design</name>
+                <campus>old</campus>
+              </school>
+            </htsql:result>
+        - uri: /fetch(school[art])/:html
+          status: 200 OK
+          headers:
+          - [Content-Type, text/html; charset=UTF-8]
+          body: |
+            <!DOCTYPE html>
+            <html>
+            <head>
+            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+            <title>school</title>
+            <style type="text/css">
+            table.htsql-output { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; margin: 1em auto; color: #000000; background-color: #ffffff; border-collapse: collapse; border: 1px double #f2f2f2; -moz-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); -webkit-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); box-shadow: 1px 1px 3px rgba(0,0,0,0.25) }
+            table.htsql-output > thead { background-color: #f2f2f2; border-bottom: 1px solid #1a1a1a }
+            table.htsql-output > thead > tr > th { font-weight: bold; padding: 0.2em 0.5em; text-align: center; vertical-align: bottom; overflow: hidden; word-wrap: break-word; border-top: 1px solid #999999; border-left: 1px solid #999999 }
+            table.htsql-output > thead > tr > th.htsql-empty-header:after { content: "\A0" }
+            table.htsql-output > tbody > tr.htsql-odd-row { background-color: #ffffff }
+            table.htsql-output > tbody > tr.htsql-even-row { background-color: #f2f2f2 }
+            table.htsql-output > tbody > tr:hover { color: #ffffff; background-color: #333333 }
+            table.htsql-output > tbody > tr > td { padding: 0.2em 0.5em; vertical-align: baseline; overflow: hidden; word-wrap: break-word; border-left: 1px solid #999999; border-right: 1px solid #999999 }
+            table.htsql-output > tbody > tr > td.htsql-integer-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-decimal-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-float-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-null-value:after { content: "\A0" }
+            table.htsql-output > tbody > tr > td.htsql-empty-value { color: #999999 }
+            table.htsql-output > tbody > tr > td.htsql-empty-value:after { content: "\2B1A" }
+            table.htsql-output > tbody > tr > td.htsql-false-value { font-style: italic }
+            table.htsql-output > tbody > tr > td.htsql-null-record-value { border-left-style: dashed; border-right-style: dashed }
+            table.htsql-output > tbody > tr > td.htsql-section { border-top: 1px dotted #999999 }
+            table.htsql-output > tbody > tr > td.htsql-index { font-size: 90%; font-weight: bold; text-align: right; width: 0; color: #999999; border-left-style: solid; border-right-color: #1a1a1a; -moz-user-select: none; -webkit-user-select: none; user-select: none }
+            div.htsql-welcome { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; text-align: center; margin: 1em auto; color: #000000; background-color: #ffffff }
+            div.htsql-welcome > h1 { font-size: 200%; font-weight: bold; margin: 1px 0 0 }
+            div.htsql-welcome > p { margin: 1px 0 0 }
+            </style>
+            </head>
+            <body>
+            <table class="htsql-output" summary="school">
+            <thead>
+            <tr><th colspan="3">school</th></tr>
+            <tr><th>code</th><th>name</th><th>campus</th></tr>
+            </thead>
+            <tbody>
+            <tr class="htsql-odd-row"><td class="htsql-string-type">art</td><td class="htsql-string-type">School of Art &amp; Design</td><td class="htsql-string-type">old</td></tr>
+            </tbody>
+            </table>
+            </body>
+            </html>
+        - uri: /fetch(school[art])/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | school                                 |
+             +------+------------------------+--------+
+             | code | name                   | campus |
+            -+------+------------------------+--------+-
+             | art  | School of Art & Design | old    |
+
+             ----
+             school[art]
+             SELECT [school].[code],
+                    [school].[name],
+                    [school].[campus]
+             FROM [ad].[school]
+             WHERE ([school].[code] = 'art')
+             ORDER BY 1 ASC
+        - uri: /fetch(school[none])/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="school.js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "record",
+                  "fields": [
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "code",
+                      "syntax": "code",
+                      "tag": "code"
+                    },
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "name",
+                      "syntax": "name",
+                      "tag": "name"
+                    },
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "campus",
+                      "syntax": "campus",
+                      "tag": "campus"
+                    }
+                  ]
+                },
+                "header": "school",
+                "syntax": "school[none]",
+                "tag": "school"
+              }
+            }
+        - uri: /fetch(school[none])/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="school.js"]
+          body: |
+            {}
+        - uri: /fetch(school[none])/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="school.csv"]
+          body: "code,name,campus\r\n,,\r\n"
+        - uri: /fetch(school[none])/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="school.tsv"]
+          body: "code\tname\tcampus\r\n\t\t\r\n"
+        - uri: /fetch(school[none])/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="school.xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml" />
+        - uri: /fetch(school[none])/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | school               |
+             +------+------+--------+
+             | code | name | campus |
+            -+------+------+--------+-
+             :      :      :        :
+
+             ----
+             school[none]
+             SELECT [school].[code],
+                    [school].[name],
+                    [school].[campus]
+             FROM [ad].[school]
+             WHERE ([school].[code] = 'none')
+             ORDER BY 1 ASC
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="_.js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "record",
+                  "fields": [
+                    {
+                      "domain": {
+                        "type": "list",
+                        "item": {
+                          "domain": {
+                            "type": "record",
+                            "fields": [
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "code",
+                                "path": "school.code",
+                                "syntax": "code",
+                                "tag": "code"
+                              },
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "name",
+                                "path": "school.name",
+                                "syntax": "name",
+                                "tag": "name"
+                              },
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "campus",
+                                "path": "school.campus",
+                                "syntax": "campus",
+                                "tag": "campus"
+                              }
+                            ]
+                          }
+                        }
+                      },
+                      "header": "school",
+                      "path": "school",
+                      "syntax": "\/school?campus='old'",
+                      "tag": "school"
+                    },
+                    {
+                      "domain": {
+                        "type": "list",
+                        "item": {
+                          "domain": {
+                            "type": "record",
+                            "fields": [
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "code",
+                                "path": "department.code",
+                                "syntax": "code",
+                                "tag": "code"
+                              },
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "name",
+                                "path": "department.name",
+                                "syntax": "name",
+                                "tag": "name"
+                              },
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "school_code",
+                                "path": "department.school_code",
+                                "syntax": "school_code",
+                                "tag": "school_code"
+                              }
+                            ]
+                          }
+                        }
+                      },
+                      "header": "department",
+                      "path": "department",
+                      "syntax": "\/department?school.campus='old'",
+                      "tag": "department"
+                    }
+                  ]
+                },
+                "path": "",
+                "syntax": "{\/school?campus='old',\/department?school.campus='old'}"
+              },
+              "data": [
+                [
+                  [
+                    "art",
+                    "School of Art & Design",
+                    "old"
+                  ],
+                  [
+                    "edu",
+                    "College of Education",
+                    "old"
+                  ],
+                  [
+                    "la",
+                    "School of Arts and Humanities",
+                    "old"
+                  ],
+                  [
+                    "ns",
+                    "School of Natural Sciences",
+                    "old"
+                  ]
+                ],
+                [
+                  [
+                    "arthis",
+                    "Art History",
+                    "la"
+                  ],
+                  [
+                    "astro",
+                    "Astronomy",
+                    "ns"
+                  ],
+                  [
+                    "chem",
+                    "Chemistry",
+                    "ns"
+                  ],
+                  [
+                    "edpol",
+                    "Educational Policy",
+                    "edu"
+                  ],
+                  [
+                    "eng",
+                    "English",
+                    "la"
+                  ],
+                  [
+                    "hist",
+                    "History",
+                    "la"
+                  ],
+                  [
+                    "lang",
+                    "Foreign Languages",
+                    "la"
+                  ],
+                  [
+                    "mth",
+                    "Mathematics",
+                    "ns"
+                  ],
+                  [
+                    "phys",
+                    "Physics",
+                    "ns"
+                  ],
+                  [
+                    "poli",
+                    "Political Science",
+                    "la"
+                  ],
+                  [
+                    "psych",
+                    "Psychology",
+                    "la"
+                  ],
+                  [
+                    "stdart",
+                    "Studio Art",
+                    "art"
+                  ],
+                  [
+                    "tched",
+                    "Teacher Education",
+                    "edu"
+                  ]
+                ]
+              ]
+            }
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="_.js"]
+          body: |
+            {
+              "0": {
+                "school": [
+                  {
+                    "code": "art",
+                    "name": "School of Art & Design",
+                    "campus": "old"
+                  },
+                  {
+                    "code": "edu",
+                    "name": "College of Education",
+                    "campus": "old"
+                  },
+                  {
+                    "code": "la",
+                    "name": "School of Arts and Humanities",
+                    "campus": "old"
+                  },
+                  {
+                    "code": "ns",
+                    "name": "School of Natural Sciences",
+                    "campus": "old"
+                  }
+                ],
+                "department": [
+                  {
+                    "code": "arthis",
+                    "name": "Art History",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "astro",
+                    "name": "Astronomy",
+                    "school_code": "ns"
+                  },
+                  {
+                    "code": "chem",
+                    "name": "Chemistry",
+                    "school_code": "ns"
+                  },
+                  {
+                    "code": "edpol",
+                    "name": "Educational Policy",
+                    "school_code": "edu"
+                  },
+                  {
+                    "code": "eng",
+                    "name": "English",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "hist",
+                    "name": "History",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "lang",
+                    "name": "Foreign Languages",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "mth",
+                    "name": "Mathematics",
+                    "school_code": "ns"
+                  },
+                  {
+                    "code": "phys",
+                    "name": "Physics",
+                    "school_code": "ns"
+                  },
+                  {
+                    "code": "poli",
+                    "name": "Political Science",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "psych",
+                    "name": "Psychology",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "stdart",
+                    "name": "Studio Art",
+                    "school_code": "art"
+                  },
+                  {
+                    "code": "tched",
+                    "name": "Teacher Education",
+                    "school_code": "edu"
+                  }
+                ]
+              }
+            }
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="_.csv"]
+          body: "code,name,campus,code,name,school_code\r\nart,School of Art & Design,old,arthis,Art
+            History,la\r\nedu,College of Education,old,astro,Astronomy,ns\r\nla,School
+            of Arts and Humanities,old,chem,Chemistry,ns\r\nns,School of Natural Sciences,old,edpol,Educational
+            Policy,edu\r\n,,,eng,English,la\r\n,,,hist,History,la\r\n,,,lang,Foreign
+            Languages,la\r\n,,,mth,Mathematics,ns\r\n,,,phys,Physics,ns\r\n,,,poli,Political
+            Science,la\r\n,,,psych,Psychology,la\r\n,,,stdart,Studio Art,art\r\n,,,tched,Teacher
+            Education,edu\r\n"
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="_.tsv"]
+          body: "code\tname\tcampus\tcode\tname\tschool_code\r\nart\tSchool of Art
+            & Design\told\tarthis\tArt History\tla\r\nedu\tCollege of Education\told\tastro\tAstronomy\tns\r\nla\tSchool
+            of Arts and Humanities\told\tchem\tChemistry\tns\r\nns\tSchool of Natural
+            Sciences\told\tedpol\tEducational Policy\tedu\r\n\t\t\teng\tEnglish\tla\r\n\t\t\thist\tHistory\tla\r\n\t\t\tlang\tForeign
+            Languages\tla\r\n\t\t\tmth\tMathematics\tns\r\n\t\t\tphys\tPhysics\tns\r\n\t\t\tpoli\tPolitical
+            Science\tla\r\n\t\t\tpsych\tPsychology\tla\r\n\t\t\tstdart\tStudio Art\tart\r\n\t\t\ttched\tTeacher
+            Education\tedu\r\n"
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="_.xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml">
+              <_>
+                <school>
+                  <code>art</code>
+                  <name>School of Art &amp; Design</name>
+                  <campus>old</campus>
+                </school>
+                <school>
+                  <code>edu</code>
+                  <name>College of Education</name>
+                  <campus>old</campus>
+                </school>
+                <school>
+                  <code>la</code>
+                  <name>School of Arts and Humanities</name>
+                  <campus>old</campus>
+                </school>
+                <school>
+                  <code>ns</code>
+                  <name>School of Natural Sciences</name>
+                  <campus>old</campus>
+                </school>
+                <department>
+                  <code>arthis</code>
+                  <name>Art History</name>
+                  <school_code>la</school_code>
+                </department>
+                <department>
+                  <code>astro</code>
+                  <name>Astronomy</name>
+                  <school_code>ns</school_code>
+                </department>
+                <department>
+                  <code>chem</code>
+                  <name>Chemistry</name>
+                  <school_code>ns</school_code>
+                </department>
+                <department>
+                  <code>edpol</code>
+                  <name>Educational Policy</name>
+                  <school_code>edu</school_code>
+                </department>
+                <department>
+                  <code>eng</code>
+                  <name>English</name>
+                  <school_code>la</school_code>
+                </department>
+                <department>
+                  <code>hist</code>
+                  <name>History</name>
+                  <school_code>la</school_code>
+                </department>
+                <department>
+                  <code>lang</code>
+                  <name>Foreign Languages</name>
+                  <school_code>la</school_code>
+                </department>
+                <department>
+                  <code>mth</code>
+                  <name>Mathematics</name>
+                  <school_code>ns</school_code>
+                </department>
+                <department>
+                  <code>phys</code>
+                  <name>Physics</name>
+                  <school_code>ns</school_code>
+                </department>
+                <department>
+                  <code>poli</code>
+                  <name>Political Science</name>
+                  <school_code>la</school_code>
+                </department>
+                <department>
+                  <code>psych</code>
+                  <name>Psychology</name>
+                  <school_code>la</school_code>
+                </department>
+                <department>
+                  <code>stdart</code>
+                  <name>Studio Art</name>
+                  <school_code>art</school_code>
+                </department>
+                <department>
+                  <code>tched</code>
+                  <name>Teacher Education</name>
+                  <school_code>edu</school_code>
+                </department>
+              </_>
+            </htsql:result>
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:html
+          status: 200 OK
+          headers:
+          - [Content-Type, text/html; charset=UTF-8]
+          body: |
+            <!DOCTYPE html>
+            <html>
+            <head>
+            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+            <title></title>
+            <style type="text/css">
+            table.htsql-output { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; margin: 1em auto; color: #000000; background-color: #ffffff; border-collapse: collapse; border: 1px double #f2f2f2; -moz-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); -webkit-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); box-shadow: 1px 1px 3px rgba(0,0,0,0.25) }
+            table.htsql-output > thead { background-color: #f2f2f2; border-bottom: 1px solid #1a1a1a }
+            table.htsql-output > thead > tr > th { font-weight: bold; padding: 0.2em 0.5em; text-align: center; vertical-align: bottom; overflow: hidden; word-wrap: break-word; border-top: 1px solid #999999; border-left: 1px solid #999999 }
+            table.htsql-output > thead > tr > th.htsql-empty-header:after { content: "\A0" }
+            table.htsql-output > tbody > tr.htsql-odd-row { background-color: #ffffff }
+            table.htsql-output > tbody > tr.htsql-even-row { background-color: #f2f2f2 }
+            table.htsql-output > tbody > tr:hover { color: #ffffff; background-color: #333333 }
+            table.htsql-output > tbody > tr > td { padding: 0.2em 0.5em; vertical-align: baseline; overflow: hidden; word-wrap: break-word; border-left: 1px solid #999999; border-right: 1px solid #999999 }
+            table.htsql-output > tbody > tr > td.htsql-integer-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-decimal-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-float-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-null-value:after { content: "\A0" }
+            table.htsql-output > tbody > tr > td.htsql-empty-value { color: #999999 }
+            table.htsql-output > tbody > tr > td.htsql-empty-value:after { content: "\2B1A" }
+            table.htsql-output > tbody > tr > td.htsql-false-value { font-style: italic }
+            table.htsql-output > tbody > tr > td.htsql-null-record-value { border-left-style: dashed; border-right-style: dashed }
+            table.htsql-output > tbody > tr > td.htsql-section { border-top: 1px dotted #999999 }
+            table.htsql-output > tbody > tr > td.htsql-index { font-size: 90%; font-weight: bold; text-align: right; width: 0; color: #999999; border-left-style: solid; border-right-color: #1a1a1a; -moz-user-select: none; -webkit-user-select: none; user-select: none }
+            div.htsql-welcome { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; text-align: center; margin: 1em auto; color: #000000; background-color: #ffffff }
+            div.htsql-welcome > h1 { font-size: 200%; font-weight: bold; margin: 1px 0 0 }
+            div.htsql-welcome > p { margin: 1px 0 0 }
+            </style>
+            </head>
+            <body>
+            <table class="htsql-output" summary="">
+            <thead>
+            <tr><th colspan="4">school</th><th colspan="4">department</th></tr>
+            <tr><th class="htsql-empty-header"></th><th>code</th><th>name</th><th>campus</th><th class="htsql-empty-header"></th><th>code</th><th>name</th><th>school_code</th></tr>
+            </thead>
+            <tbody>
+            <tr class="htsql-odd-row"><td class="htsql-index">1</td><td class="htsql-string-type">art</td><td class="htsql-string-type">School of Art &amp; Design</td><td class="htsql-string-type">old</td><td class="htsql-index">1</td><td class="htsql-string-type">arthis</td><td class="htsql-string-type">Art History</td><td class="htsql-string-type">la</td></tr>
+            <tr class="htsql-even-row"><td class="htsql-index">2</td><td class="htsql-string-type">edu</td><td class="htsql-string-type">College of Education</td><td class="htsql-string-type">old</td><td class="htsql-index">2</td><td class="htsql-string-type">astro</td><td class="htsql-string-type">Astronomy</td><td class="htsql-string-type">ns</td></tr>
+            <tr class="htsql-odd-row"><td class="htsql-index">3</td><td class="htsql-string-type">la</td><td class="htsql-string-type">School of Arts and Humanities</td><td class="htsql-string-type">old</td><td class="htsql-index">3</td><td class="htsql-string-type">chem</td><td class="htsql-string-type">Chemistry</td><td class="htsql-string-type">ns</td></tr>
+            <tr class="htsql-even-row"><td rowspan="10" class="htsql-index">4</td><td rowspan="10" class="htsql-string-type">ns</td><td rowspan="10" class="htsql-string-type">School of Natural Sciences</td><td rowspan="10" class="htsql-string-type">old</td><td class="htsql-index">4</td><td class="htsql-string-type">edpol</td><td class="htsql-string-type">Educational Policy</td><td class="htsql-string-type">edu</td></tr>
+            <tr class="htsql-odd-row"><td class="htsql-index">5</td><td class="htsql-string-type">eng</td><td class="htsql-string-type">English</td><td class="htsql-string-type">la</td></tr>
+            <tr class="htsql-even-row"><td class="htsql-index">6</td><td class="htsql-string-type">hist</td><td class="htsql-string-type">History</td><td class="htsql-string-type">la</td></tr>
+            <tr class="htsql-odd-row"><td class="htsql-index">7</td><td class="htsql-string-type">lang</td><td class="htsql-string-type">Foreign Languages</td><td class="htsql-string-type">la</td></tr>
+            <tr class="htsql-even-row"><td class="htsql-index">8</td><td class="htsql-string-type">mth</td><td class="htsql-string-type">Mathematics</td><td class="htsql-string-type">ns</td></tr>
+            <tr class="htsql-odd-row"><td class="htsql-index">9</td><td class="htsql-string-type">phys</td><td class="htsql-string-type">Physics</td><td class="htsql-string-type">ns</td></tr>
+            <tr class="htsql-even-row"><td class="htsql-index">10</td><td class="htsql-string-type">poli</td><td class="htsql-string-type">Political Science</td><td class="htsql-string-type">la</td></tr>
+            <tr class="htsql-odd-row"><td class="htsql-index">11</td><td class="htsql-string-type">psych</td><td class="htsql-string-type">Psychology</td><td class="htsql-string-type">la</td></tr>
+            <tr class="htsql-even-row"><td class="htsql-index">12</td><td class="htsql-string-type">stdart</td><td class="htsql-string-type">Studio Art</td><td class="htsql-string-type">art</td></tr>
+            <tr class="htsql-odd-row"><td class="htsql-index">13</td><td class="htsql-string-type">tched</td><td class="htsql-string-type">Teacher Education</td><td class="htsql-string-type">edu</td></tr>
+            </tbody>
+            </table>
+            </body>
+            </html>
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | school                                        | department                                |
+             +------+-------------------------------+--------+--------+--------------------+-------------+
+             | code | name                          | campus | code   | name               | school_code |
+            -+------+-------------------------------+--------+--------+--------------------+-------------+-
+             | art  | School of Art & Design        | old    | arthis | Art History        | la          |
+             | edu  | College of Education          | old    | astro  | Astronomy          | ns          |
+             | la   | School of Arts and Humanities | old    | chem   | Chemistry          | ns          |
+             | ns   | School of Natural Sciences    | old    | edpol  | Educational Policy | edu         |
+             :      :                               :        | eng    | English            | la          |
+             :      :                               :        | hist   | History            | la          |
+             :      :                               :        | lang   | Foreign Languages  | la          |
+             :      :                               :        | mth    | Mathematics        | ns          |
+             :      :                               :        | phys   | Physics            | ns          |
+             :      :                               :        | poli   | Political Science  | la          |
+             :      :                               :        | psych  | Psychology         | la          |
+             :      :                               :        | stdart | Studio Art         | art         |
+             :      :                               :        | tched  | Teacher Education  | edu         |
+
+             ----
+             {/school?campus='old',/department?school.campus='old'}
+             SELECT 1
+
+               SELECT [school].[code],
+                      [school].[name],
+                      [school].[campus]
+               FROM [ad].[school]
+               WHERE ([school].[campus] = 'old')
+               ORDER BY 1 ASC
+
+               SELECT [department].[code],
+                      [department].[name],
+                      [department].[school_code]
+               FROM [ad].[department]
+                    LEFT OUTER JOIN [ad].[school]
+                                    ON ([department].[school_code] = [school].[code])
+               WHERE ([school].[campus] = 'old')
+               ORDER BY 1 ASC
       - id: commands
         tests:
         - uri: /school/:fetch
           headers:
           - [Content-Type, text/plain; charset=UTF-8]
           body: |
-            bind error: function 'fetch' expects a segment argument:
+            encode error: a singular expression is expected:
                 /fetch(school)
                        ^^^^^^
         - uri: /school/:html/:fetch
           headers:
           - [Content-Type, text/plain; charset=UTF-8]
           body: |
-            bind error: function 'fetch' expects a segment argument:
+            encode error: a singular expression is expected:
                 /fetch(school)
                        ^^^^^^
         - uri: /html(school)

test/output/mysql.yaml

                    SELECT TRUE
 
                      SELECT TRUE
+      - id: scalar-data
+        tests:
+        - uri: /fetch(null)/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="null.js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "untyped"
+                },
+                "header": "null",
+                "syntax": "null",
+                "tag": "null"
+              }
+            }
+        - uri: /fetch(null)/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="null.js"]
+          body: |
+            {}
+        - uri: /fetch(null)/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="null.csv"]
+          body: "null\r\n\"\"\r\n"
+        - uri: /fetch(null)/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="null.tsv"]
+          body: "null\r\n\"\"\r\n"
+        - uri: /fetch(null)/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="null.xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml" />
+        - uri: /fetch(null)/:html
+          status: 200 OK
+          headers:
+          - [Content-Type, text/html; charset=UTF-8]
+          body: |
+            <!DOCTYPE html>
+            <html>
+            <head>
+            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+            <title>null</title>
+            <style type="text/css">
+            table.htsql-output { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; margin: 1em auto; color: #000000; background-color: #ffffff; border-collapse: collapse; border: 1px double #f2f2f2; -moz-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); -webkit-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); box-shadow: 1px 1px 3px rgba(0,0,0,0.25) }
+            table.htsql-output > thead { background-color: #f2f2f2; border-bottom: 1px solid #1a1a1a }
+            table.htsql-output > thead > tr > th { font-weight: bold; padding: 0.2em 0.5em; text-align: center; vertical-align: bottom; overflow: hidden; word-wrap: break-word; border-top: 1px solid #999999; border-left: 1px solid #999999 }
+            table.htsql-output > thead > tr > th.htsql-empty-header:after { content: "\A0" }
+            table.htsql-output > tbody > tr.htsql-odd-row { background-color: #ffffff }
+            table.htsql-output > tbody > tr.htsql-even-row { background-color: #f2f2f2 }
+            table.htsql-output > tbody > tr:hover { color: #ffffff; background-color: #333333 }
+            table.htsql-output > tbody > tr > td { padding: 0.2em 0.5em; vertical-align: baseline; overflow: hidden; word-wrap: break-word; border-left: 1px solid #999999; border-right: 1px solid #999999 }
+            table.htsql-output > tbody > tr > td.htsql-integer-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-decimal-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-float-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-null-value:after { content: "\A0" }
+            table.htsql-output > tbody > tr > td.htsql-empty-value { color: #999999 }
+            table.htsql-output > tbody > tr > td.htsql-empty-value:after { content: "\2B1A" }
+            table.htsql-output > tbody > tr > td.htsql-false-value { font-style: italic }
+            table.htsql-output > tbody > tr > td.htsql-null-record-value { border-left-style: dashed; border-right-style: dashed }
+            table.htsql-output > tbody > tr > td.htsql-section { border-top: 1px dotted #999999 }
+            table.htsql-output > tbody > tr > td.htsql-index { font-size: 90%; font-weight: bold; text-align: right; width: 0; color: #999999; border-left-style: solid; border-right-color: #1a1a1a; -moz-user-select: none; -webkit-user-select: none; user-select: none }
+            div.htsql-welcome { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; text-align: center; margin: 1em auto; color: #000000; background-color: #ffffff }
+            div.htsql-welcome > h1 { font-size: 200%; font-weight: bold; margin: 1px 0 0 }
+            div.htsql-welcome > p { margin: 1px 0 0 }
+            </style>
+            </head>
+            <body>
+            <table class="htsql-output" summary="null">
+            <thead>
+            <tr><th>null</th></tr>
+            </thead>
+            <tbody>
+            <tr class="htsql-odd-row"><td class="htsql-untyped-type htsql-null-value"></td></tr>
+            </tbody>
+            </table>
+            </body>
+            </html>
+        - uri: /fetch(null)/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | null |
+            -+------+-
+             |      |
+
+             ----
+             null
+             SELECT TRUE
+             FROM (SELECT TRUE AS `!`) AS `!`
+             WHERE FALSE
+        - uri: /fetch({})/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="_.js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "record",
+                  "fields": []
+                },
+                "path": "",
+                "syntax": "{}"
+              },
+              "data": []
+            }
+        - uri: /fetch({})/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="_.js"]
+          body: |
+            {
+              "0": {}
+            }
+        - uri: /fetch({})/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="_.csv"]
+          body: ''
+        - uri: /fetch({})/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="_.tsv"]
+          body: ''
+        - uri: /fetch({})/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="_.xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml">
+              <_ />
+            </htsql:result>
+        - uri: /fetch({})/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: ''
+        - uri: /fetch(count(school))/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="count(school).js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "integer"
+                },
+                "header": "count(school)",
+                "syntax": "count(school)"
+              },
+              "data": 9
+            }
+        - uri: /fetch(count(school))/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="count(school).js"]
+          body: |
+            {
+              "0": 9
+            }
+        - uri: /fetch(count(school))/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="count(school).csv"]
+          body: "count(school)\r\n9\r\n"
+        - uri: /fetch(count(school))/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="count(school).tsv"]
+          body: "count(school)\r\n9\r\n"
+        - uri: /fetch(count(school))/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="count(school).xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml">
+              <_>9</_>
+            </htsql:result>
+        - uri: /fetch(count(school))/:html
+          status: 200 OK
+          headers:
+          - [Content-Type, text/html; charset=UTF-8]
+          body: |
+            <!DOCTYPE html>
+            <html>
+            <head>
+            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+            <title>count(school)</title>
+            <style type="text/css">
+            table.htsql-output { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; margin: 1em auto; color: #000000; background-color: #ffffff; border-collapse: collapse; border: 1px double #f2f2f2; -moz-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); -webkit-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); box-shadow: 1px 1px 3px rgba(0,0,0,0.25) }
+            table.htsql-output > thead { background-color: #f2f2f2; border-bottom: 1px solid #1a1a1a }
+            table.htsql-output > thead > tr > th { font-weight: bold; padding: 0.2em 0.5em; text-align: center; vertical-align: bottom; overflow: hidden; word-wrap: break-word; border-top: 1px solid #999999; border-left: 1px solid #999999 }
+            table.htsql-output > thead > tr > th.htsql-empty-header:after { content: "\A0" }
+            table.htsql-output > tbody > tr.htsql-odd-row { background-color: #ffffff }
+            table.htsql-output > tbody > tr.htsql-even-row { background-color: #f2f2f2 }
+            table.htsql-output > tbody > tr:hover { color: #ffffff; background-color: #333333 }
+            table.htsql-output > tbody > tr > td { padding: 0.2em 0.5em; vertical-align: baseline; overflow: hidden; word-wrap: break-word; border-left: 1px solid #999999; border-right: 1px solid #999999 }
+            table.htsql-output > tbody > tr > td.htsql-integer-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-decimal-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-float-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-null-value:after { content: "\A0" }
+            table.htsql-output > tbody > tr > td.htsql-empty-value { color: #999999 }
+            table.htsql-output > tbody > tr > td.htsql-empty-value:after { content: "\2B1A" }
+            table.htsql-output > tbody > tr > td.htsql-false-value { font-style: italic }
+            table.htsql-output > tbody > tr > td.htsql-null-record-value { border-left-style: dashed; border-right-style: dashed }
+            table.htsql-output > tbody > tr > td.htsql-section { border-top: 1px dotted #999999 }
+            table.htsql-output > tbody > tr > td.htsql-index { font-size: 90%; font-weight: bold; text-align: right; width: 0; color: #999999; border-left-style: solid; border-right-color: #1a1a1a; -moz-user-select: none; -webkit-user-select: none; user-select: none }
+            div.htsql-welcome { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; text-align: center; margin: 1em auto; color: #000000; background-color: #ffffff }
+            div.htsql-welcome > h1 { font-size: 200%; font-weight: bold; margin: 1px 0 0 }
+            div.htsql-welcome > p { margin: 1px 0 0 }
+            </style>
+            </head>
+            <body>
+            <table class="htsql-output" summary="count(school)">
+            <thead>
+            <tr><th>count(school)</th></tr>
+            </thead>
+            <tbody>
+            <tr class="htsql-odd-row"><td class="htsql-integer-type">9</td></tr>
+            </tbody>
+            </table>
+            </body>
+            </html>
+        - uri: /fetch(count(school))/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | count(school) |
+            -+---------------+-
+             |             9 |
+
+             ----
+             count(school)
+             SELECT `school`.`count`
+             FROM (SELECT COUNT(TRUE) AS `count`
+                   FROM `school`) AS `school`
+             WHERE (`school`.`count` IS NOT NULL)
+        - uri: /fetch(school[art])/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="school.js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "record",
+                  "fields": [
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "code",
+                      "syntax": "code",
+                      "tag": "code"
+                    },
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "name",
+                      "syntax": "name",
+                      "tag": "name"
+                    },
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "campus",
+                      "syntax": "campus",
+                      "tag": "campus"
+                    }
+                  ]
+                },
+                "header": "school",
+                "syntax": "school[art]",
+                "tag": "school"
+              },
+              "data": [
+                "art",
+                "School of Art & Design",
+                "old"
+              ]
+            }
+        - uri: /fetch(school[art])/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="school.js"]
+          body: |
+            {
+              "school": {
+                "code": "art",
+                "name": "School of Art & Design",
+                "campus": "old"
+              }
+            }
+        - uri: /fetch(school[art])/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="school.csv"]
+          body: "code,name,campus\r\nart,School of Art & Design,old\r\n"
+        - uri: /fetch(school[art])/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="school.tsv"]
+          body: "code\tname\tcampus\r\nart\tSchool of Art & Design\told\r\n"
+        - uri: /fetch(school[art])/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="school.xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml">
+              <school>
+                <code>art</code>
+                <name>School of Art &amp; Design</name>
+                <campus>old</campus>
+              </school>
+            </htsql:result>
+        - uri: /fetch(school[art])/:html
+          status: 200 OK
+          headers:
+          - [Content-Type, text/html; charset=UTF-8]
+          body: |
+            <!DOCTYPE html>
+            <html>
+            <head>
+            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+            <title>school</title>
+            <style type="text/css">
+            table.htsql-output { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; margin: 1em auto; color: #000000; background-color: #ffffff; border-collapse: collapse; border: 1px double #f2f2f2; -moz-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); -webkit-box-shadow: 1px 1px 3px rgba(0,0,0,0.25); box-shadow: 1px 1px 3px rgba(0,0,0,0.25) }
+            table.htsql-output > thead { background-color: #f2f2f2; border-bottom: 1px solid #1a1a1a }
+            table.htsql-output > thead > tr > th { font-weight: bold; padding: 0.2em 0.5em; text-align: center; vertical-align: bottom; overflow: hidden; word-wrap: break-word; border-top: 1px solid #999999; border-left: 1px solid #999999 }
+            table.htsql-output > thead > tr > th.htsql-empty-header:after { content: "\A0" }
+            table.htsql-output > tbody > tr.htsql-odd-row { background-color: #ffffff }
+            table.htsql-output > tbody > tr.htsql-even-row { background-color: #f2f2f2 }
+            table.htsql-output > tbody > tr:hover { color: #ffffff; background-color: #333333 }
+            table.htsql-output > tbody > tr > td { padding: 0.2em 0.5em; vertical-align: baseline; overflow: hidden; word-wrap: break-word; border-left: 1px solid #999999; border-right: 1px solid #999999 }
+            table.htsql-output > tbody > tr > td.htsql-integer-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-decimal-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-float-type { text-align: right }
+            table.htsql-output > tbody > tr > td.htsql-null-value:after { content: "\A0" }
+            table.htsql-output > tbody > tr > td.htsql-empty-value { color: #999999 }
+            table.htsql-output > tbody > tr > td.htsql-empty-value:after { content: "\2B1A" }
+            table.htsql-output > tbody > tr > td.htsql-false-value { font-style: italic }
+            table.htsql-output > tbody > tr > td.htsql-null-record-value { border-left-style: dashed; border-right-style: dashed }
+            table.htsql-output > tbody > tr > td.htsql-section { border-top: 1px dotted #999999 }
+            table.htsql-output > tbody > tr > td.htsql-index { font-size: 90%; font-weight: bold; text-align: right; width: 0; color: #999999; border-left-style: solid; border-right-color: #1a1a1a; -moz-user-select: none; -webkit-user-select: none; user-select: none }
+            div.htsql-welcome { font-family: "Arial", sans-serif; font-size: 13px; line-height: 1.3; text-align: center; margin: 1em auto; color: #000000; background-color: #ffffff }
+            div.htsql-welcome > h1 { font-size: 200%; font-weight: bold; margin: 1px 0 0 }
+            div.htsql-welcome > p { margin: 1px 0 0 }
+            </style>
+            </head>
+            <body>
+            <table class="htsql-output" summary="school">
+            <thead>
+            <tr><th colspan="3">school</th></tr>
+            <tr><th>code</th><th>name</th><th>campus</th></tr>
+            </thead>
+            <tbody>
+            <tr class="htsql-odd-row"><td class="htsql-string-type">art</td><td class="htsql-string-type">School of Art &amp; Design</td><td class="htsql-string-type">old</td></tr>
+            </tbody>
+            </table>
+            </body>
+            </html>
+        - uri: /fetch(school[art])/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | school                                 |
+             +------+------------------------+--------+
+             | code | name                   | campus |
+            -+------+------------------------+--------+-
+             | art  | School of Art & Design | old    |
+
+             ----
+             school[art]
+             SELECT `school`.`code`,
+                    `school`.`name`,
+                    `school`.`campus`
+             FROM `school`
+             WHERE (`school`.`code` = 'art')
+             ORDER BY 1 ASC
+        - uri: /fetch(school[none])/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="school.js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "record",
+                  "fields": [
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "code",
+                      "syntax": "code",
+                      "tag": "code"
+                    },
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "name",
+                      "syntax": "name",
+                      "tag": "name"
+                    },
+                    {
+                      "domain": {
+                        "type": "string"
+                      },
+                      "header": "campus",
+                      "syntax": "campus",
+                      "tag": "campus"
+                    }
+                  ]
+                },
+                "header": "school",
+                "syntax": "school[none]",
+                "tag": "school"
+              }
+            }
+        - uri: /fetch(school[none])/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="school.js"]
+          body: |
+            {}
+        - uri: /fetch(school[none])/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="school.csv"]
+          body: "code,name,campus\r\n,,\r\n"
+        - uri: /fetch(school[none])/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="school.tsv"]
+          body: "code\tname\tcampus\r\n\t\t\r\n"
+        - uri: /fetch(school[none])/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]
+          - [Content-Disposition, inline; filename="school.xml"]
+          body: |
+            <?xml version="1.0" encoding="UTF-8" ?>
+            <htsql:result xmlns:htsql="http://htsql.org/2010/xml" />
+        - uri: /fetch(school[none])/:txt
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | school               |
+             +------+------+--------+
+             | code | name | campus |
+            -+------+------+--------+-
+             :      :      :        :
+
+             ----
+             school[none]
+             SELECT `school`.`code`,
+                    `school`.`name`,
+                    `school`.`campus`
+             FROM `school`
+             WHERE (`school`.`code` = 'none')
+             ORDER BY 1 ASC
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:raw
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="_.js"]
+          body: |
+            {
+              "meta": {
+                "domain": {
+                  "type": "record",
+                  "fields": [
+                    {
+                      "domain": {
+                        "type": "list",
+                        "item": {
+                          "domain": {
+                            "type": "record",
+                            "fields": [
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "code",
+                                "path": "school.code",
+                                "syntax": "code",
+                                "tag": "code"
+                              },
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "name",
+                                "path": "school.name",
+                                "syntax": "name",
+                                "tag": "name"
+                              },
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "campus",
+                                "path": "school.campus",
+                                "syntax": "campus",
+                                "tag": "campus"
+                              }
+                            ]
+                          }
+                        }
+                      },
+                      "header": "school",
+                      "path": "school",
+                      "syntax": "\/school?campus='old'",
+                      "tag": "school"
+                    },
+                    {
+                      "domain": {
+                        "type": "list",
+                        "item": {
+                          "domain": {
+                            "type": "record",
+                            "fields": [
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "code",
+                                "path": "department.code",
+                                "syntax": "code",
+                                "tag": "code"
+                              },
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "name",
+                                "path": "department.name",
+                                "syntax": "name",
+                                "tag": "name"
+                              },
+                              {
+                                "domain": {
+                                  "type": "string"
+                                },
+                                "header": "school_code",
+                                "path": "department.school_code",
+                                "syntax": "school_code",
+                                "tag": "school_code"
+                              }
+                            ]
+                          }
+                        }
+                      },
+                      "header": "department",
+                      "path": "department",
+                      "syntax": "\/department?school.campus='old'",
+                      "tag": "department"
+                    }
+                  ]
+                },
+                "path": "",
+                "syntax": "{\/school?campus='old',\/department?school.campus='old'}"
+              },
+              "data": [
+                [
+                  [
+                    "art",
+                    "School of Art & Design",
+                    "old"
+                  ],
+                  [
+                    "edu",
+                    "College of Education",
+                    "old"
+                  ],
+                  [
+                    "la",
+                    "School of Arts and Humanities",
+                    "old"
+                  ],
+                  [
+                    "ns",
+                    "School of Natural Sciences",
+                    "old"
+                  ]
+                ],
+                [
+                  [
+                    "arthis",
+                    "Art History",
+                    "la"
+                  ],
+                  [
+                    "astro",
+                    "Astronomy",
+                    "ns"
+                  ],
+                  [
+                    "chem",
+                    "Chemistry",
+                    "ns"
+                  ],
+                  [
+                    "edpol",
+                    "Educational Policy",
+                    "edu"
+                  ],
+                  [
+                    "eng",
+                    "English",
+                    "la"
+                  ],
+                  [
+                    "hist",
+                    "History",
+                    "la"
+                  ],
+                  [
+                    "lang",
+                    "Foreign Languages",
+                    "la"
+                  ],
+                  [
+                    "mth",
+                    "Mathematics",
+                    "ns"
+                  ],
+                  [
+                    "phys",
+                    "Physics",
+                    "ns"
+                  ],
+                  [
+                    "poli",
+                    "Political Science",
+                    "la"
+                  ],
+                  [
+                    "psych",
+                    "Psychology",
+                    "la"
+                  ],
+                  [
+                    "stdart",
+                    "Studio Art",
+                    "art"
+                  ],
+                  [
+                    "tched",
+                    "Teacher Education",
+                    "edu"
+                  ]
+                ]
+              ]
+            }
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:json
+          status: 200 OK
+          headers:
+          - [Content-Type, application/javascript]
+          - [Content-Disposition, inline; filename="_.js"]
+          body: |
+            {
+              "0": {
+                "school": [
+                  {
+                    "code": "art",
+                    "name": "School of Art & Design",
+                    "campus": "old"
+                  },
+                  {
+                    "code": "edu",
+                    "name": "College of Education",
+                    "campus": "old"
+                  },
+                  {
+                    "code": "la",
+                    "name": "School of Arts and Humanities",
+                    "campus": "old"
+                  },
+                  {
+                    "code": "ns",
+                    "name": "School of Natural Sciences",
+                    "campus": "old"
+                  }
+                ],
+                "department": [
+                  {
+                    "code": "arthis",
+                    "name": "Art History",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "astro",
+                    "name": "Astronomy",
+                    "school_code": "ns"
+                  },
+                  {
+                    "code": "chem",
+                    "name": "Chemistry",
+                    "school_code": "ns"
+                  },
+                  {
+                    "code": "edpol",
+                    "name": "Educational Policy",
+                    "school_code": "edu"
+                  },
+                  {
+                    "code": "eng",
+                    "name": "English",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "hist",
+                    "name": "History",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "lang",
+                    "name": "Foreign Languages",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "mth",
+                    "name": "Mathematics",
+                    "school_code": "ns"
+                  },
+                  {
+                    "code": "phys",
+                    "name": "Physics",
+                    "school_code": "ns"
+                  },
+                  {
+                    "code": "poli",
+                    "name": "Political Science",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "psych",
+                    "name": "Psychology",
+                    "school_code": "la"
+                  },
+                  {
+                    "code": "stdart",
+                    "name": "Studio Art",
+                    "school_code": "art"
+                  },
+                  {
+                    "code": "tched",
+                    "name": "Teacher Education",
+                    "school_code": "edu"
+                  }
+                ]
+              }
+            }
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:csv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/csv; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="_.csv"]
+          body: "code,name,campus,code,name,school_code\r\nart,School of Art & Design,old,arthis,Art
+            History,la\r\nedu,College of Education,old,astro,Astronomy,ns\r\nla,School
+            of Arts and Humanities,old,chem,Chemistry,ns\r\nns,School of Natural Sciences,old,edpol,Educational
+            Policy,edu\r\n,,,eng,English,la\r\n,,,hist,History,la\r\n,,,lang,Foreign
+            Languages,la\r\n,,,mth,Mathematics,ns\r\n,,,phys,Physics,ns\r\n,,,poli,Political
+            Science,la\r\n,,,psych,Psychology,la\r\n,,,stdart,Studio Art,art\r\n,,,tched,Teacher
+            Education,edu\r\n"
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:tsv
+          status: 200 OK
+          headers:
+          - [Content-Type, text/tab-separated-values; charset=UTF-8]
+          - [Content-Disposition, attachment; filename="_.tsv"]
+          body: "code\tname\tcampus\tcode\tname\tschool_code\r\nart\tSchool of Art
+            & Design\told\tarthis\tArt History\tla\r\nedu\tCollege of Education\told\tastro\tAstronomy\tns\r\nla\tSchool
+            of Arts and Humanities\told\tchem\tChemistry\tns\r\nns\tSchool of Natural
+            Sciences\told\tedpol\tEducational Policy\tedu\r\n\t\t\teng\tEnglish\tla\r\n\t\t\thist\tHistory\tla\r\n\t\t\tlang\tForeign
+            Languages\tla\r\n\t\t\tmth\tMathematics\tns\r\n\t\t\tphys\tPhysics\tns\r\n\t\t\tpoli\tPolitical
+            Science\tla\r\n\t\t\tpsych\tPsychology\tla\r\n\t\t\tstdart\tStudio Art\tart\r\n\t\t\ttched\tTeacher
+            Education\tedu\r\n"
+        - uri: /fetch({/school?campus='old', /department?school.campus='old'})/:xml
+          status: 200 OK
+          headers:
+          - [Content-Type, application/xml]