git.iko.soy/rowtype-yoga/purescript-yoga-postgres
on main help sign in
Add clause ordering and compile-fail tests
commit6793714b7def9780cdc9dc7d32b6c9a350573cfc authorMark <mark.eibes@gmail.com> dateFri 13 Feb 2026, 19:11 (8 months ago) parentc1a6a65
8 files changed+162
compile-fail-tests/DoubleSelect.purs+17 compile-fail-tests/InvalidColumn.purs+17 compile-fail-tests/LimitWithoutSelect.purs+19 compile-fail-tests/OnConflictWithoutInsert.purs+17 compile-fail-tests/OrderByBeforeSelect.purs+17 compile-fail-tests/SelectAfterOrderBy.purs+17 compile-fail-tests/WhereOnInsert.purs+19 compile-fail-tests/run.sh+39
compile-fail-tests/DoubleSelect.pursnew file+17
@@ -0,0 +1,17 @@
1+-- EXPECT: Lacks
2+module Test.CompileFail.DoubleSelect where
3+
4+import Prelude
5+import Data.Tuple.Nested (type (/\))
6+import Type.Proxy (Proxy(..))
7+import Yoga.Postgres.Schema
8+
9+type UsersTable = Table "users"
10+ ( id :: Column Int (PrimaryKey /\ AutoIncrement)
11+ , name :: Column String None
12+ )
13+
14+usersTable :: Proxy UsersTable
15+usersTable = Proxy
16+
17+bad = from usersTable # selectAll # selectAll
compile-fail-tests/InvalidColumn.pursnew file+17
@@ -0,0 +1,17 @@
1+-- EXPECT: TypesDoNotUnify
2+module Test.CompileFail.InvalidColumn where
3+
4+import Prelude
5+import Data.Tuple.Nested (type (/\))
6+import Type.Proxy (Proxy(..))
7+import Yoga.Postgres.Schema
8+
9+type UsersTable = Table "users"
10+ ( id :: Column Int (PrimaryKey /\ AutoIncrement)
11+ , name :: Column String None
12+ )
13+
14+usersTable :: Proxy UsersTable
15+usersTable = Proxy
16+
17+bad = from usersTable # selectAll # where_ @"nonexistent = $x"
compile-fail-tests/LimitWithoutSelect.pursnew file+19
@@ -0,0 +1,19 @@
1+-- EXPECT: Cons
2+module Test.CompileFail.LimitWithoutSelect where
3+
4+import Data.Maybe (Maybe(..))
5+import Prelude
6+import Data.Tuple.Nested (type (/\))
7+import Type.Proxy (Proxy(..))
8+import Yoga.Postgres.Schema
9+
10+type UsersTable = Table "users"
11+ ( id :: Column Int (PrimaryKey /\ AutoIncrement)
12+ , name :: Column String None
13+ , age :: Column (Maybe Int) None
14+ )
15+
16+usersTable :: Proxy UsersTable
17+usersTable = Proxy
18+
19+bad = from usersTable # set { name: "Bob" } # limit 10
compile-fail-tests/OnConflictWithoutInsert.pursnew file+17
@@ -0,0 +1,17 @@
1+-- EXPECT: Cons
2+module Test.CompileFail.OnConflictWithoutInsert where
3+
4+import Prelude
5+import Data.Tuple.Nested (type (/\))
6+import Type.Proxy (Proxy(..))
7+import Yoga.Postgres.Schema
8+
9+type UsersTable = Table "users"
10+ ( id :: Column Int (PrimaryKey /\ AutoIncrement)
11+ , name :: Column String None
12+ )
13+
14+usersTable :: Proxy UsersTable
15+usersTable = Proxy
16+
17+bad = from usersTable # selectAll # onConflictDoNothing @"name"
compile-fail-tests/OrderByBeforeSelect.pursnew file+17
@@ -0,0 +1,17 @@
1+-- EXPECT: Lacks
2+module Test.CompileFail.OrderByBeforeSelect where
3+
4+import Prelude
5+import Data.Tuple.Nested (type (/\))
6+import Type.Proxy (Proxy(..))
7+import Yoga.Postgres.Schema
8+
9+type UsersTable = Table "users"
10+ ( id :: Column Int (PrimaryKey /\ AutoIncrement)
11+ , name :: Column String None
12+ )
13+
14+usersTable :: Proxy UsersTable
15+usersTable = Proxy
16+
17+bad = from usersTable # orderBy @"name"
compile-fail-tests/SelectAfterOrderBy.pursnew file+17
@@ -0,0 +1,17 @@
1+-- EXPECT: Lacks
2+module Test.CompileFail.SelectAfterOrderBy where
3+
4+import Prelude
5+import Data.Tuple.Nested (type (/\))
6+import Type.Proxy (Proxy(..))
7+import Yoga.Postgres.Schema
8+
9+type UsersTable = Table "users"
10+ ( id :: Column Int (PrimaryKey /\ AutoIncrement)
11+ , name :: Column String None
12+ )
13+
14+usersTable :: Proxy UsersTable
15+usersTable = Proxy
16+
17+bad = from usersTable # selectAll # orderBy @"name" # select @"name"
compile-fail-tests/WhereOnInsert.pursnew file+19
@@ -0,0 +1,19 @@
1+-- EXPECT: Lacks
2+module Test.CompileFail.WhereOnInsert where
3+
4+import Data.Maybe (Maybe(..))
5+import Prelude
6+import Data.Tuple.Nested (type (/\))
7+import Type.Proxy (Proxy(..))
8+import Yoga.Postgres.Schema
9+
10+type UsersTable = Table "users"
11+ ( id :: Column Int (PrimaryKey /\ AutoIncrement)
12+ , name :: Column String None
13+ , age :: Column (Maybe Int) None
14+ )
15+
16+usersTable :: Proxy UsersTable
17+usersTable = Proxy
18+
19+bad = from usersTable # insert { name: "Alice", age: Nothing } # where_ @"id = $id"
compile-fail-tests/run.shnew file+39
@@ -0,0 +1,39 @@
1+#!/bin/bash
2+cd "$(dirname "$0")/.."
3+
4+# Build the library first
5+bunx spago build > /dev/null 2>&1
6+
7+PASS=0
8+FAIL=0
9+TOTAL=0
10+
11+for f in compile-fail-tests/*.purs; do
12+ EXPECT=$(head -1 "$f" | sed 's/-- EXPECT: //')
13+ NAME=$(basename "$f" .purs)
14+ TOTAL=$((TOTAL + 1))
15+
16+ # Rewrite module name and copy into src/ temporarily
17+ sed "s/^module .*/module Yoga.Postgres.CompileFailTest where/" "$f" > "src/_CompileFailTest.purs"
18+ OUTPUT=$(bunx spago build 2>&1) || true
19+ rm -f "src/_CompileFailTest.purs"
20+
21+ if echo "$OUTPUT" | grep -q "Build succeeded"; then
22+ echo "FAIL $NAME — compiled successfully (should have failed)"
23+ FAIL=$((FAIL + 1))
24+ elif echo "$OUTPUT" | grep -q "$EXPECT"; then
25+ echo "PASS $NAME — failed with expected: $EXPECT"
26+ PASS=$((PASS + 1))
27+ else
28+ echo "FAIL $NAME — failed but without expected '$EXPECT'"
29+ echo " Got: $(echo "$OUTPUT" | grep "ERROR" | head -3)"
30+ FAIL=$((FAIL + 1))
31+ fi
32+done
33+
34+echo ""
35+echo "$PASS passed, $FAIL failed out of $TOTAL compile-fail tests"
36+
37+if [ "$FAIL" -ne 0 ]; then
38+ exit 1
39+fi