git.iko.soy/rowtype-yoga/purescript-yoga-scylladb
on main help sign in
Move pure schema tests before Docker tests, add builder pattern tests
commit0d559f79693e0177067d299644b1f5dca7030ca5 authorMark <mark.eibes@gmail.com> dateFri 20 Feb 2026, 21:50 (7 months ago) parent045cc56
13 files changed+227
compile-fail/AllowFilteringWithoutSelect.purs+15 compile-fail/DoubleSelect.purs+15 compile-fail/DoubleWhere.purs+15 compile-fail/IfExistsWithoutWhere.purs+15 compile-fail/IfNotExistsWithoutInsert.purs+15 compile-fail/InsertAfterSelect.purs+16 compile-fail/LimitWithoutSelect.purs+15 compile-fail/OrderByWithoutSelect.purs+15 compile-fail/SelectAfterDelete.purs+15 compile-fail/UsingTTLWithoutInsert.purs+15 compile-fail/WhereAfterInsert.purs+16 compile-fail/WhereBeforeDML.purs+15 compile-fail/run.sh+45
compile-fail/AllowFilteringWithoutSelect.pursnew file+15
@@ -0,0 +1,15 @@
1+-- expect: HasClause "select"
2+module CompileFail.AllowFilteringWithoutSelect where
3+import Prelude
4+
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+
10+type UsersTable = S.Table "users"
11+ ( id :: Scylla.UUID # S.PartitionKey
12+ , name :: String
13+ )
14+
15+bad = S.from (Proxy :: Proxy UsersTable) # S.delete # S.allowFiltering
compile-fail/DoubleSelect.pursnew file+15
@@ -0,0 +1,15 @@
1+-- expect: Lacks "select"
2+module CompileFail.DoubleSelect where
3+import Prelude
4+
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+
10+type UsersTable = S.Table "users"
11+ ( id :: Scylla.UUID # S.PartitionKey
12+ , name :: String
13+ )
14+
15+bad = S.from (Proxy :: Proxy UsersTable) # S.selectAll # S.selectAll
compile-fail/DoubleWhere.pursnew file+15
@@ -0,0 +1,15 @@
1+-- expect: Lacks "where"
2+module CompileFail.DoubleWhere where
3+import Prelude
4+
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+
10+type UsersTable = S.Table "users"
11+ ( id :: Scylla.UUID # S.PartitionKey
12+ , name :: String
13+ )
14+
15+bad = S.from (Proxy :: Proxy UsersTable) # S.selectAll # S.where_ @"id = $id" # S.where_ @"name = $name"
compile-fail/IfExistsWithoutWhere.pursnew file+15
@@ -0,0 +1,15 @@
1+-- expect: HasClause "where"
2+module CompileFail.IfExistsWithoutWhere where
3+import Prelude
4+
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+
10+type UsersTable = S.Table "users"
11+ ( id :: Scylla.UUID # S.PartitionKey
12+ , name :: String
13+ )
14+
15+bad = S.from (Proxy :: Proxy UsersTable) # S.delete # S.ifExists
compile-fail/IfNotExistsWithoutInsert.pursnew file+15
@@ -0,0 +1,15 @@
1+-- expect: HasClause "insert"
2+module CompileFail.IfNotExistsWithoutInsert where
3+import Prelude
4+
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+
10+type UsersTable = S.Table "users"
11+ ( id :: Scylla.UUID # S.PartitionKey
12+ , name :: String
13+ )
14+
15+bad = S.from (Proxy :: Proxy UsersTable) # S.selectAll # S.ifNotExists
compile-fail/InsertAfterSelect.pursnew file+16
@@ -0,0 +1,16 @@
1+-- expect: Lacks @Type "select"
2+module CompileFail.InsertAfterSelect where
3+
4+import Prelude
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+import Unsafe.Coerce (unsafeCoerce)
10+
11+type UsersTable = S.Table "users"
12+ ( id :: Scylla.UUID # S.PartitionKey
13+ , name :: String
14+ )
15+
16+bad = S.from (Proxy :: Proxy UsersTable) # S.selectAll # S.insert { id: (unsafeCoerce "" :: Scylla.UUID), name: "x" }
compile-fail/LimitWithoutSelect.pursnew file+15
@@ -0,0 +1,15 @@
1+-- expect: HasClause "select"
2+module CompileFail.LimitWithoutSelect where
3+import Prelude
4+
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+
10+type UsersTable = S.Table "users"
11+ ( id :: Scylla.UUID # S.PartitionKey
12+ , name :: String
13+ )
14+
15+bad = S.from (Proxy :: Proxy UsersTable) # S.delete # S.limit @"10"
compile-fail/OrderByWithoutSelect.pursnew file+15
@@ -0,0 +1,15 @@
1+-- expect: HasClause "select"
2+module CompileFail.OrderByWithoutSelect where
3+import Prelude
4+
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+
10+type UsersTable = S.Table "users"
11+ ( id :: Scylla.UUID # S.PartitionKey
12+ , name :: String
13+ )
14+
15+bad = S.from (Proxy :: Proxy UsersTable) # S.orderBy @"id DESC"
compile-fail/SelectAfterDelete.pursnew file+15
@@ -0,0 +1,15 @@
1+-- expect: Lacks "delete"
2+module CompileFail.SelectAfterDelete where
3+import Prelude
4+
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+
10+type UsersTable = S.Table "users"
11+ ( id :: Scylla.UUID # S.PartitionKey
12+ , name :: String
13+ )
14+
15+bad = S.from (Proxy :: Proxy UsersTable) # S.delete # S.selectAll
compile-fail/UsingTTLWithoutInsert.pursnew file+15
@@ -0,0 +1,15 @@
1+-- expect: HasClause "insert"
2+module CompileFail.UsingTTLWithoutInsert where
3+import Prelude
4+
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+
10+type UsersTable = S.Table "users"
11+ ( id :: Scylla.UUID # S.PartitionKey
12+ , name :: String
13+ )
14+
15+bad = S.from (Proxy :: Proxy UsersTable) # S.selectAll # S.usingTTL @"3600"
compile-fail/WhereAfterInsert.pursnew file+16
@@ -0,0 +1,16 @@
1+-- expect: WHERE requires a preceding SELECT, UPDATE (set), or DELETE
2+module CompileFail.WhereAfterInsert where
3+
4+import Prelude
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+import Unsafe.Coerce (unsafeCoerce)
10+
11+type UsersTable = S.Table "users"
12+ ( id :: Scylla.UUID # S.PartitionKey
13+ , name :: String
14+ )
15+
16+bad = S.from (Proxy :: Proxy UsersTable) # S.insert { id: (unsafeCoerce "" :: Scylla.UUID), name: "x" } # S.where_ @"id = $id"
compile-fail/WhereBeforeDML.pursnew file+15
@@ -0,0 +1,15 @@
1+-- expect: WHERE requires a preceding SELECT, UPDATE (set), or DELETE
2+module CompileFail.WhereBeforeDML where
3+import Prelude
4+
5+import Yoga.ScyllaDB.Schema as S
6+import Yoga.ScyllaDB.ScyllaDB as Scylla
7+import Type.Function (type (#))
8+import Type.Proxy (Proxy(..))
9+
10+type UsersTable = S.Table "users"
11+ ( id :: Scylla.UUID # S.PartitionKey
12+ , name :: String
13+ )
14+
15+bad = S.from (Proxy :: Proxy UsersTable) # S.where_ @"id = $id"
compile-fail/run.shnew file+45
@@ -0,0 +1,45 @@
1+#!/usr/bin/env bash
2+set -euo pipefail
3+
4+cd "$(dirname "$0")/.."
5+
6+PASS=0
7+FAIL=0
8+ERRORS=()
9+
10+for f in compile-fail/*.purs; do
11+ name=$(basename "$f" .purs)
12+ # Extract expected error pattern from first line comment: -- expect: <pattern>
13+ expected=$(head -1 "$f" | sed -n 's/^-- expect: //p')
14+
15+ output=$(eval "purs compile 'src/**/*.purs' '.spago/p/*/src/**/*.purs' '$f' --output output-compile-fail" 2>&1 || true)
16+
17+ if echo "$output" | grep -q "^Error found:"; then
18+ if [ -n "$expected" ]; then
19+ if echo "$output" | grep -q "$expected"; then
20+ printf " \033[32m✓\033[0m %s \033[2m(%s)\033[0m\n" "$name" "$expected"
21+ ((PASS++))
22+ else
23+ ERRORS+=("WRONG ERROR: $name — expected '$expected' but got different error")
24+ ((FAIL++))
25+ fi
26+ else
27+ printf " \033[32m✓\033[0m %s correctly rejected\n" "$name"
28+ ((PASS++))
29+ fi
30+ else
31+ ERRORS+=("UNEXPECTED PASS: $name compiled but should have failed")
32+ ((FAIL++))
33+ fi
34+done
35+
36+rm -rf output-compile-fail
37+
38+echo ""
39+echo "Compile-fail: $PASS passed, $FAIL failed"
40+
41+for err in "${ERRORS[@]+"${ERRORS[@]}"}"; do
42+ printf " \033[31m✗ %s\033[0m\n" "$err"
43+done
44+
45+[ "$FAIL" -eq 0 ]