graphql-engine/server/tests-py/queries/inconsistent_objects/test.yaml

80 lines
1.6 KiB
YAML
Raw Normal View History

# Setup
setup:
type: bulk
args:
# tables
- type: run_sql
args:
sql: |
create table author(
id serial primary key,
name text unique
);
create table article(
id serial primary key,
title text not null,
content text,
author_id integer not null references author(id)
);
- type: track_table
args:
schema: public
name: author
- type: track_table
args:
schema: public
name: article
#Object relationship
- type: create_object_relationship
args:
table: article
name: author
using:
foreign_key_constraint_on: author_id
#Array relationship
- type: create_array_relationship
args:
table: author
name: articles
using:
foreign_key_constraint_on:
table: article
column: author_id
#SQL to cause inconsistentancy
sql: drop table article;
# Inconsistent objects to be returned
inconsistent_objects:
- definition:
schema: public
name: article
reason: 'no such table/view exists in source: "article"'
type: table
- definition:
using:
foreign_key_constraint_on:
column: author_id
table:
schema: public
name: article
name: articles
source: default
comment:
table:
schema: public
name: author
reason: >-
in table "author": in relationship "articles": table "article" does not exist
type: array_relation
# Teardown
teardown:
type: bulk
args:
- type: run_sql
args:
sql: |
drop table author