git.iko.soy/rowtype-yoga/purescript-yoga-postgres
on main help sign in
Fix trailing comma bug in ParseSelect, add compile-fail test
commit3a0a994bde1c3c5eca42c46ec359210b3ca5b64a authorMark <mark.eibes@gmail.com> dateFri 13 Feb 2026, 21:08 (8 months ago) parent66861a6
2 files changed+26−1
compile-fail-tests/LeadingCommaInSelect.purs+20 src/Yoga/Postgres/Schema.purs+6−1
compile-fail-tests/LeadingCommaInSelect.pursnew file+20
@@ -0,0 +1,20 @@
1+-- EXPECT: Unexpected comma in SELECT clause (missing column name)
2+module Test.CompileFail.LeadingCommaInSelect where
3+
4+import Prelude
5+import Data.Maybe (Maybe(..))
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+ , email :: Column String Unique
14+ , age :: Column (Maybe Int) None
15+ )
16+
17+usersTable :: Proxy UsersTable
18+usersTable = Proxy
19+
20+bad = from usersTable # select @",name"
src/Yoga/Postgres/Schema.purs+6−1
@@ -581,8 +581,13 @@ else instance
581581class ParseSelectGo :: Symbol -> Symbol -> Symbol -> Row (Row Type) -> RL.RowList Type -> RL.RowList Type -> Constraint
582582class ParseSelectGo head tail acc tables accRL outRL | head tail acc tables accRL -> outRL
583583
584−-- Comma: emit column, continue
584+-- Leading/double comma: no column name before comma
585585instance
586+ Fail (Text "Unexpected comma in SELECT clause (missing column name)") =>
587+ ParseSelectGo "," tail "" tables accRL outRL
588+
589+-- Comma: emit column, continue
590+else instance
586591 ( ResolveColumn acc tables (Column typ constraints)
587592 , SplitOnDot acc _hasDot _table colName
588593 , SkipSpaces tail rest