Commits

Kirill Simonov  committed 48d1479

Added tests demonstrating the new link `program.part_of`.

  • Participants
  • Parent commits 35b2337

Comments (0)

Files changed (3)

File test/input/schema.yaml

 
   # Program -> School (parental)
   - uri: /(program?school='egn'&code='umech').school
+  # Program -> Program (singular, self-referencial)
+  - uri: /(program?school='egn'&code='umech').part_of
+  # Program -> Program (reverse self-referential)
+  # FIXME: broken! No way to indicate a reverse self-referential link.
+  # The query below, in fact, produces a direct self-referential link.
+  - uri: /(program?school='egn'&code='umech').program
   # Program -> Student
   - uri: /(program?school='egn'&code='umech').student
   # Program -> Program Requirement

File test/output/pgsql.yaml

              WHERE ("program"."school" = 'egn')
                    AND ("program"."code" = 'umech')
              ORDER BY "program"."school" ASC, "program"."code" ASC
+        - uri: /(program?school='egn'&code='umech').part_of
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | (program?school='egn'&code='umech').part_of                       |
+            -+-------------------------------------------------------------------+-
+             | school | code | title                          | degree | part_of |
+            -+--------+------+--------------------------------+--------+---------+-
+             | egn    | gme  | M.S. in Mechanical Engineering | ms     |         |
+                                                                           (1 row)
+
+             ----
+             /(program?school='egn'&code='umech').part_of
+             SELECT "program_2"."school",
+                    "program_2"."code",
+                    "program_2"."title",
+                    "program_2"."degree",
+                    "program_2"."part_of"
+             FROM "ad"."program" AS "program_1"
+                  INNER JOIN "ad"."program" AS "program_2"
+                             ON (("program_1"."school" = "program_2"."school") AND ("program_1"."part_of" = "program_2"."code"))
+             WHERE ("program_1"."school" = 'egn')
+                   AND ("program_1"."code" = 'umech')
+             ORDER BY "program_1"."school" ASC, "program_1"."code" ASC
+        - uri: /(program?school='egn'&code='umech').program
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | (program?school='egn'&code='umech').program                       |
+            -+-------------------------------------------------------------------+-
+             | school | code | title                          | degree | part_of |
+            -+--------+------+--------------------------------+--------+---------+-
+             | egn    | gme  | M.S. in Mechanical Engineering | ms     |         |
+                                                                           (1 row)
+
+             ----
+             /(program?school='egn'&code='umech').program
+             SELECT "program_2"."school",
+                    "program_2"."code",
+                    "program_2"."title",
+                    "program_2"."degree",
+                    "program_2"."part_of"
+             FROM "ad"."program" AS "program_1"
+                  INNER JOIN "ad"."program" AS "program_2"
+                             ON (("program_1"."school" = "program_2"."school") AND ("program_1"."part_of" = "program_2"."code"))
+             WHERE ("program_1"."school" = 'egn')
+                   AND ("program_1"."code" = 'umech')
+             ORDER BY "program_1"."school" ASC, "program_1"."code" ASC
         - uri: /(program?school='egn'&code='umech').student
           status: 200 OK
           headers:
                | arthis | art         |                     3 |                     3 |
                | astro  | ns          |                     6 |                     6 |
                | be     | egn         |                     8 |                     8 |
-               | bursar |             |                     0 |                     0 |
+               | bursar |             |                     0 |                       |
                | capmrk | bus         |                     5 |                     5 |
-               | career |             |                     0 |                     0 |
+               | career |             |                     0 |                       |
                | chem   | ns          |                     6 |                     6 |
                | comp   | egn         |                     8 |                     8 |
                | corpfi | bus         |                     5 |                     5 |
                | lang   | la          |                     9 |                     9 |
                | me     | egn         |                     8 |                     8 |
                | mth    | ns          |                     6 |                     6 |
-               | parent |             |                     0 |                     0 |
+               | parent |             |                     0 |                       |
                | phys   | ns          |                     6 |                     6 |
                | pia    | mus         |                     0 |                     0 |
                | poli   | la          |                     9 |                     9 |
               -+-------------------------------------------------------------------------------------------+-
                | name                          | count(department) | this(){count(department)}?name!~'art' |
               -+-------------------------------+-------------------+---------------------------------------+-
-               | School of Art and Design      |                 2 |                                     0 |
+               | School of Art and Design      |                 2 |                                       |
                | School of Business            |                 3 |                                     3 |
                | College of Education          |                 2 |                                     2 |
                | School of Engineering         |                 4 |                                     4 |
-               | School of Arts and Humanities |                 5 |                                     0 |
+               | School of Arts and Humanities |                 5 |                                       |
                | School of Music & Dance       |                 4 |                                     4 |
                | School of Natural Sciences    |                 4 |                                     4 |
                | Public Honorariums            |                 0 |                                     0 |

File test/output/sqlite.yaml

              WHERE ("program"."school" = 'egn')
                    AND ("program"."code" = 'umech')
              ORDER BY "program"."school" ASC, "program"."code" ASC
+        - uri: /(program?school='egn'&code='umech').part_of
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | (program?school='egn'&code='umech').part_of                       |
+            -+-------------------------------------------------------------------+-
+             | school | code | title                          | degree | part_of |
+            -+--------+------+--------------------------------+--------+---------+-
+             | egn    | gme  | M.S. in Mechanical Engineering | ms     |         |
+                                                                           (1 row)
+
+             ----
+             /(program?school='egn'&code='umech').part_of
+             SELECT "program_2"."school",
+                    "program_2"."code",
+                    "program_2"."title",
+                    "program_2"."degree",
+                    "program_2"."part_of"
+             FROM "program" AS "program_1"
+                  INNER JOIN "program" AS "program_2"
+                             ON (("program_1"."school" = "program_2"."school") AND ("program_1"."part_of" = "program_2"."code"))
+             WHERE ("program_1"."school" = 'egn')
+                   AND ("program_1"."code" = 'umech')
+             ORDER BY "program_1"."school" ASC, "program_1"."code" ASC
+        - uri: /(program?school='egn'&code='umech').program
+          status: 200 OK
+          headers:
+          - [Content-Type, text/plain; charset=UTF-8]
+          body: |2
+             | (program?school='egn'&code='umech').program                       |
+            -+-------------------------------------------------------------------+-
+             | school | code | title                          | degree | part_of |
+            -+--------+------+--------------------------------+--------+---------+-
+             | egn    | gme  | M.S. in Mechanical Engineering | ms     |         |
+                                                                           (1 row)
+
+             ----
+             /(program?school='egn'&code='umech').program
+             SELECT "program_2"."school",
+                    "program_2"."code",
+                    "program_2"."title",
+                    "program_2"."degree",
+                    "program_2"."part_of"
+             FROM "program" AS "program_1"
+                  INNER JOIN "program" AS "program_2"
+                             ON (("program_1"."school" = "program_2"."school") AND ("program_1"."part_of" = "program_2"."code"))
+             WHERE ("program_1"."school" = 'egn')
+                   AND ("program_1"."code" = 'umech')
+             ORDER BY "program_1"."school" ASC, "program_1"."code" ASC
         - uri: /(program?school='egn'&code='umech').student
           status: 200 OK
           headers: