supabase-postgres.git / summary / log / commit / refs
commit 0110bc3a8e182390b8c2bf00c19d5871e793f0de
Author: Oliver Rice <github@oliverrice.com>
Commit: GitHub <noreply@github.com>
Date: Fri Aug 23 17:14:19 2024 +0000
add pgrouting tests (#1162)
nix/tests/expected/pgrouting.out | 31 +++++++++++++++++++++++++++++++
nix/tests/sql/pgrouting.sql | 27 +++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/nix/tests/expected/pgrouting.out b/nix/tests/expected/pgrouting.out
new file mode 100644
index 00000000..2362a72e
--- /dev/null
+++ b/nix/tests/expected/pgrouting.out
@@ -0,0 +1,31 @@
+create schema v;
+-- create the roads table
+create table v.roads (
+ id serial primary key,
+ source integer,
+ target integer,
+ cost double precision
+);
+-- insert sample data into roads table
+insert into v.roads (source, target, cost) values
+(1, 2, 1.0),
+(2, 3, 1.0),
+(3, 4, 1.0),
+(1, 3, 2.5),
+(3, 5, 2.0);
+-- create a function to use pgRouting to find the shortest path
+select * from pgr_dijkstra(
+ 'select id, source, target, cost from v.roads',
+ 1, -- start node
+ 4 -- end node
+);
+ seq | path_seq | node | edge | cost | agg_cost
+-----+----------+------+------+------+----------
+ 1 | 1 | 1 | 1 | 1 | 0
+ 2 | 2 | 2 | 2 | 1 | 1
+ 3 | 3 | 3 | 3 | 1 | 2
+ 4 | 4 | 4 | -1 | 0 | 3
+(4 rows)
+
+drop schema v cascade;
+NOTICE: drop cascades to table v.roads
diff --git a/nix/tests/sql/pgrouting.sql b/nix/tests/sql/pgrouting.sql
new file mode 100644
index 00000000..e3af5621
--- /dev/null
+++ b/nix/tests/sql/pgrouting.sql
@@ -0,0 +1,27 @@
+create schema v;
+
+-- create the roads table
+create table v.roads (
+ id serial primary key,
+ source integer,
+ target integer,
+ cost double precision
+);
+
+-- insert sample data into roads table
+insert into v.roads (source, target, cost) values
+(1, 2, 1.0),
+(2, 3, 1.0),
+(3, 4, 1.0),
+(1, 3, 2.5),
+(3, 5, 2.0);
+
+-- create a function to use pgRouting to find the shortest path
+select * from pgr_dijkstra(
+ 'select id, source, target, cost from v.roads',
+ 1, -- start node
+ 4 -- end node
+);
+
+drop schema v cascade;
+
[parent: 10582dada8a2]