-- GRAPH_TABLE in views
-- The query in the view definition is intentionally complex to test one view with many
--- features like label disjunction, lateral references, WHERE clauses in graph
--- patterns.
+-- features like label disjunction, lateral references, WHERE clauses on graph
+-- pattern elements as well as on the whole graph pattern.
CREATE VIEW customers_us AS
SELECT g.* FROM x1,
GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US' AND c.customer_id = x1.a)
-[IS customer_orders | customer_wishlists ]->
(l IS orders | wishlists)-[ IS list_items]->(p IS products)
+ WHERE p.price > 0
COLUMNS (c.name AS customer_name, p.name AS product_name, p.price, x1.a AS a)) g
ORDER BY customer_name, product_name;
-- Dropping properties or labels used by a view is not allowed
HINT: Use DROP ... CASCADE to drop the dependent objects too.
-- ruleutils reverse parsing
SELECT pg_get_viewdef('customers_us'::regclass);
- pg_get_viewdef
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- SELECT g.customer_name, +
- g.product_name, +
- g.price, +
- g.a +
- FROM x1, +
- GRAPH_TABLE (myshop MATCH (c IS customers WHERE (((c.address)::text = 'US'::text) AND (c.customer_id = x1.a)))-[IS customer_orders|customer_wishlists]->(l IS orders|wishlists)-[IS list_items]->(p IS products) COLUMNS (c.name AS customer_name, p.name AS product_name, p.price AS price, x1.a AS a)) g+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ SELECT g.customer_name, +
+ g.product_name, +
+ g.price, +
+ g.a +
+ FROM x1, +
+ GRAPH_TABLE (myshop MATCH (c IS customers WHERE (((c.address)::text = 'US'::text) AND (c.customer_id = x1.a)))-[IS customer_orders|customer_wishlists]->(l IS orders|wishlists)-[IS list_items]->(p IS products) WHERE (p.price > (0)::numeric) COLUMNS (c.name AS customer_name, p.name AS product_name, p.price AS price, x1.a AS a)) g+
ORDER BY g.customer_name, g.product_name;
(1 row)
-- GRAPH_TABLE in views
-- The query in the view definition is intentionally complex to test one view with many
--- features like label disjunction, lateral references, WHERE clauses in graph
--- patterns.
+-- features like label disjunction, lateral references, WHERE clauses on graph
+-- pattern elements as well as on the whole graph pattern.
CREATE VIEW customers_us AS
SELECT g.* FROM x1,
GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US' AND c.customer_id = x1.a)
-[IS customer_orders | customer_wishlists ]->
(l IS orders | wishlists)-[ IS list_items]->(p IS products)
+ WHERE p.price > 0
COLUMNS (c.name AS customer_name, p.name AS product_name, p.price, x1.a AS a)) g
ORDER BY customer_name, product_name;
-- Dropping properties or labels used by a view is not allowed