graphql-engine/v3/crates/engine/tests/db_definition.sql
Daniel Harvey 75ced29d11 Resolve nested object boolean expressions (#680)
<!-- Thank you for submitting this PR! :) -->

## Description

This adds the ability to describe nested object boolean expressions,
which become `fieldPath` items in the generated
`ndc_models::ComparisonTarget::Column` items. This allows us to describe
filtering a `User` based on some element in their nested `address` field
(like `postcode`, for example).

Like the other `BooleanExpressionType` work, this remains behind a
feature flag so should make no user-facing changes.

It is also missing a whole heap of metadata resolve checks, going to
follow with these after doing the happy path to unblock other work.

V3_GIT_ORIGIN_REV_ID: c89e2942a651d349fca97706affcf40d91afeefb
2024-06-11 12:57:21 +00:00

166 lines
4.1 KiB
SQL

/*****************************************
Non chinook tables
******************************************/
CREATE TABLE public.article (
id integer NOT NULL,
title text,
author_id integer,
CONSTRAINT article_pkey PRIMARY KEY (id)
);
COPY public.article (id, title, author_id) FROM stdin;
1 The Next 700 Programming Languages 1
2 Why Functional Programming Matters 2
3 The Design And Implementation Of Programming Languages 2
4 The Mechanical Evaluation of Expressions 1
5 Generalizing monads to arrows 2
\.
CREATE TABLE author (
id integer NOT NULL,
first_name text,
last_name text,
CONSTRAINT author_pkey PRIMARY KEY (id)
);
COPY public.author (id, first_name, last_name) FROM stdin;
1 Peter Landin
2 John Hughes
\.
CREATE TABLE public.movie_analytics (
id integer NOT NULL,
movie_id integer NOT NULL,
num_votes_day integer,
num_views_day integer,
num_users_faved integer,
num_users_watchlisted integer,
total_votes integer,
prev_day_scores integer,
movie_name text
);
CREATE SEQUENCE public.movie_analytics_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.movie_analytics_id_seq OWNER TO postgres;
--
-- Data for Name: movie_analytics; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY public.movie_analytics (id, movie_id, num_votes_day, num_views_day, num_users_faved, num_users_watchlisted, total_votes, prev_day_scores, movie_name) FROM stdin;
1 1 10 22 9 11 578 8 Titanic
2 2 8 13 4 3 432 7 Slumdog Millionaire
3 3 17 34 14 11 849 9 Godfather
\.
--
-- Name: movie_analytics movie_analytics_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.movie_analytics
ADD CONSTRAINT movie_analytics_pkey PRIMARY KEY (id);
--
-- Name: article FK_article_author_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
--
-- Name: movie_analytics_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.movie_analytics_id_seq', 3, true);
--
-- Name: article article_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
--
-- Name: movie_analytics_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.movie_analytics_id_seq OWNED BY public.movie_analytics.id;
--
-- Name: movie_analytics id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.movie_analytics ALTER COLUMN id SET DEFAULT nextval('public.movie_analytics_id_seq'::regclass);
-- `institution` table for testing queries into JSON objects
CREATE TYPE public.country AS (name text, continent text);
CREATE TYPE public.location AS (city text, country country, campuses text []);
CREATE TYPE public.staff AS (
first_name text,
last_name text,
specialities text [],
favourite_artist_id int
);
CREATE TABLE public.institution (
id integer NOT NULL,
name text,
location location,
staff staff [],
departments text [],
CONSTRAINT institution_pkey PRIMARY KEY (id)
);
INSERT INTO public.institution (id, name, location, staff, departments)
VALUES (
1,
'Queen Mary University of London',
ROW(
'London',
ROW('UK','Europe') :: country,
ARRAY ['Mile End','Whitechapel','Charterhouse Square','West Smithfield']
)::location,
ARRAY [ROW('Peter','Landin',ARRAY['Computer Science','Education'],
1
)::staff ],
ARRAY ['Humanities and Social Sciences','Science and Engineering','Medicine and Dentistry']
),
(
2,
'Chalmers University of Technology',
ROW(
'Gothenburg',
ROW('Sweden','Europe') :: country,
ARRAY ['Johanneberg','Lindholmen']
)::location,
ARRAY [ROW('John','Hughes',ARRAY['Computer Science','Functional Programming','Software Testing'],
2
)::staff,
ROW(
'Koen',
'Claessen',
ARRAY ['Computer Science','Functional Programming','Automated Reasoning'],
3
)::staff ],
ARRAY ['Architecture and Civil Engineering','Computer Science and Engineering','Electrical Engineering','Physics','Industrial and Materials Science']
),
(
3,
'University of Nowhere',
null,
null,
ARRAY ['nothing',null]
);