Skip to content

Commit 28184fa

Browse files
committed
fix some cross-database compatibility issues
1 parent 49f997d commit 28184fa

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Set COMPOSE_PROFILES to one of the following: postgres, mysql, mssql
2-
COMPOSE_PROFILES=mssql
1+
# Set COMPOSE_PROFILES to one of the following: postgres, mysql, mssql. If set to mssql, you will need to change the depends_on propery in docker-compose.yml
2+
COMPOSE_PROFILES=mysql

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ services:
77
volumes:
88
- .:/var/www
99
depends_on:
10-
mssql: { condition: service_healthy }
11-
# [ "${COMPOSE_PROFILES-postgres}" ]
10+
# mssql: { condition: service_healthy }
11+
[ "${COMPOSE_PROFILES-postgres}" ]
1212
environment:
1313
DATABASE_URL: ${COMPOSE_PROFILES-postgres}://root:Password123!@${COMPOSE_PROFILES:-postgres}/sqlpage
1414
postgres:

index.sql

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,10 @@ select 'chart' as component,
6666
'Collatz conjecture' as title,
6767
'area' as type;
6868

69-
SELECT 'syracuse' as series,
70-
x,
71-
y
69+
SELECT 'syracuse' as series, x, y
7270
FROM (
73-
VALUES (0, 15), (1, 46), (2, 23), (3, 70), (4, 35), (5, 106), (6, 53), (7, 160), (8, 80), (9, 40), (10, 20), (11, 10), (12, 5)
74-
) AS cnt(x, y);
71+
SELECT 0 AS x, 15 AS y UNION SELECT 1, 46 UNION SELECT 2, 23 UNION SELECT 3, 70 UNION SELECT 4, 35 UNION SELECT 5, 106 UNION SELECT 6, 53 UNION SELECT 7, 160 UNION SELECT 8, 80 UNION SELECT 9, 40 UNION SELECT 10, 20 UNION SELECT 11, 10 UNION SELECT 12, 5
72+
) AS syracuse ORDER BY x;
7573

7674
select 'table' as component,
7775
true as sort,
@@ -89,6 +87,9 @@ select 'Jane',
8987
select 'card' as component,
9088
5 as columns;
9189

90+
WITH nums(x) AS (
91+
SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10
92+
)
9293
SELECT a.x || ' times ' || b.x as title,
9394
CASE
9495
a.x % 4
@@ -100,12 +101,12 @@ SELECT a.x || ' times ' || b.x as title,
100101
a.x || ' x ' || b.x || ' = ' || (a.x * b.x) as description,
101102
'This is basic math' as footer,
102103
'?x=' || a.x as link -- This is the interesting part. Each card has a link. When you click the card, the current page is reloaded with '?x=a' appended to the end of the URL
103-
FROM (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) as a(x),
104-
(VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10)) as b(x)
104+
FROM nums as a, nums as b
105105
WHERE -- The powerful thing is here
106106
$x IS NULL
107107
OR -- The syntax $x allows us to extract the value 'a' when the URL ends with '?x=a'. It will be null if the URL does not contain '?x='
108-
b.x = $x::DECIMAL;
108+
b.x = $x::DECIMAL
109+
ORDER BY a.x, b.x;
109110
-- So when we click the card for "a times b", we will reload the page, and display only the multiplication table of a
110111
---------------------------
111112
-- FORMS --

0 commit comments

Comments
 (0)