graphql-engine/server/tests-py/queries/v1/track_table/setup.yaml
Antoine Leblanc eb81d6947a
server: add tests for track_table of a materialized view (#4155)
* server: add tests for track_table of a materialized view

In the context of #91, we discovered that materialized views were
already "automagically" supported; to ensure we don't regress on this
accidental but welcome change, this patch adds simple tests.

This is basically just a copy of `track_untrack_table`, but for
materialized views.

* Expand abbreviations

Co-authored-by: Alexis King <lexi.lambda@gmail.com>
2020-03-24 12:35:34 +05:30

58 lines
1.3 KiB
YAML

type: bulk
args:
- type: run_sql
args:
sql: |
CREATE TABLE author (
id SERIAL PRIMARY KEY,
name TEXT UNIQUE,
remarks TEXT
);
CREATE TABLE article (
id SERIAL PRIMARY KEY,
title TEXT,
author_id INTEGER REFERENCES author(id)
);
CREATE TABLE test1 (
id SERIAL PRIMARY KEY
);
CREATE TABLE test2 (
id SERIAL PRIMARY KEY
);
CREATE TABLE hge_tests.resident (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL
);
INSERT INTO author (name) VALUES
('Author 1'),
('Author 2');
INSERT INTO article (title, author_id) VALUES
('Lorem ipsum dolor sit amet', 1),
('lolcats: an anthology', 2),
('consectetur adipiscing elit', 1);
INSERT INTO hge_tests.resident (name, age) VALUES
('Resident 1', 23),
('Resident 2', 31);
CREATE MATERIALIZED VIEW articles AS
SELECT article.title, author.name
FROM article
LEFT JOIN author ON author.id = article.author_id
;
CREATE OR REPLACE FUNCTION test1()
RETURNS SETOF test2 AS $$
SELECT * FROM test2
$$ LANGUAGE sql STABLE;