summaryrefslogtreecommitdiff
path: root/lib/query/tests
diff options
context:
space:
mode:
Diffstat (limited to 'lib/query/tests')
-rw-r--r--lib/query/tests/create.t40
1 files changed, 36 insertions, 4 deletions
diff --git a/lib/query/tests/create.t b/lib/query/tests/create.t
index 46e3940..7f41ad0 100644
--- a/lib/query/tests/create.t
+++ b/lib/query/tests/create.t
@@ -156,8 +156,7 @@ to a list is an integer column constrained by a foreign key to the list table:
> {
> "list": [
> {
- > "id": "user_type_list",
- > "source": "csv"
+ > "id": "user_type_list"
> }
> ],
> "content": [
@@ -192,8 +191,7 @@ target column referencing the list table:
> {
> "list": [
> {
- > "id": "user_type_list",
- > "source": "csv"
+ > "id": "user_type_list"
> }
> ],
> "content": [
@@ -223,3 +221,37 @@ target column referencing the list table:
, "target" INTEGER NOT NULL
, FOREIGN KEY("parent") REFERENCES "entity"("id")
, FOREIGN KEY("target") REFERENCES "user_type_list"("id") )
+
+A list with fields gets one column per field. A reference field in the list is
+a foreign key to the targeted list table:
+
+ $ tests --schema "country_list" "user_type_list" <<EOF
+ > {
+ > "list": [
+ > {
+ > "id": "country_list",
+ > "field": [
+ > { "name": "name", "label": {}, "type": "text" }
+ > ]
+ > },
+ > {
+ > "id": "user_type_list",
+ > "field": [
+ > {
+ > "name": "country",
+ > "label": {},
+ > "type": { "content": "country_list" }
+ > }
+ > ]
+ > }
+ > ],
+ > "content": [ { "id": "entity" } ]
+ > }
+ > EOF
+ CREATE TABLE "country_list"
+ ( "id" INTEGER PRIMARY KEY
+ , "name" VARCHAR )
+ CREATE TABLE "user_type_list"
+ ( "id" INTEGER PRIMARY KEY
+ , "country" INTEGER
+ , FOREIGN KEY("country") REFERENCES "country_list"("id") )