git.iko.soy/rowtype-yoga/purescript-yoga-postgres
on main help sign in
Skip string literals in WHERE clause parser
commit9d0c81872998e95ab3ac3bd7611a9c8f2ffefd66 authorMark <mark.eibes@gmail.com> dateSun 15 Feb 2026, 15:49 (8 months ago) parent2110995
3 files changed+40−3
compile-fail-tests/UnclosedStringLiteral.purs+1−1 compile-fail-tests/UnclosedStringLiteralJoin.purs+29 src/Yoga/Postgres/Schema.purs+10−2
compile-fail-tests/UnclosedStringLiteral.purs+1−1
@@ -1,4 +1,4 @@
1−-- EXPECT: Unclosed string literal in WHERE clause
1+-- EXPECT: Unclosed string literal
22module Test.CompileFail.UnclosedStringLiteral where
33
44import Prelude
compile-fail-tests/UnclosedStringLiteralJoin.pursnew file+29
@@ -0,0 +1,29 @@
1+-- EXPECT: Unclosed string literal
2+module Test.CompileFail.UnclosedStringLiteralJoin where
3+
4+import Prelude
5+import Data.Maybe (Maybe(..))
6+import Type.Function (type (#))
7+import Type.Proxy (Proxy(..))
8+import Yoga.Postgres.Schema
9+
10+type UsersTable = Table "users"
11+ ( id :: Int # PrimaryKey # AutoIncrement
12+ , name :: String
13+ , email :: String # Unique
14+ , age :: Maybe Int
15+ )
16+
17+type PostsTable = Table "posts"
18+ ( id :: Int # PrimaryKey # AutoIncrement
19+ , user_id :: Int
20+ , title :: String
21+ )
22+
23+usersTable :: Proxy UsersTable
24+usersTable = Proxy
25+
26+postsTable :: Proxy PostsTable
27+postsTable = Proxy
28+
29+bad = from usersTable # select @"users.name" # innerJoin @"users.id = 'unclosed" postsTable
src/Yoga/Postgres/Schema.purs+10−2
@@ -419,7 +419,7 @@ else instance Symbol.Cons head tail result => SkipSpacesGo head tail result
419419class SkipStringLiteral :: Symbol -> Symbol -> Constraint
420420class SkipStringLiteral sym rest | sym -> rest
421421
422−instance Fail (Text "Unclosed string literal in WHERE clause") => SkipStringLiteral "" rest
422+instance Fail (Text "Unclosed string literal") => SkipStringLiteral "" rest
423423else instance
424424 ( Symbol.Cons h t sym
425425 , SkipStringLiteralGo h t rest
@@ -432,7 +432,7 @@ class SkipStringLiteralGo head tail rest | head tail -> rest
432432-- Closing quote: done
433433instance SkipStringLiteralGo "'" tail tail
434434-- End of string without closing quote
435−else instance Fail (Text "Unclosed string literal in WHERE clause") => SkipStringLiteralGo h "" rest
435+else instance Fail (Text "Unclosed string literal") => SkipStringLiteralGo h "" rest
436436-- Any other char: skip and continue
437437else instance
438438 ( Symbol.Cons nextH nextT tail
@@ -2191,6 +2191,14 @@ else instance (FlushJoinWord acc tables, ValidateJoinCondition tail tables) => V
21912191else instance (FlushJoinWord acc tables, ValidateJoinCondition tail tables) => ValidateJoinCondGo "(" tail acc tables
21922192else instance (FlushJoinWord acc tables, ValidateJoinCondition tail tables) => ValidateJoinCondGo ")" tail acc tables
21932193
2194+-- String literal: skip content between quotes
2195+else instance
2196+ ( FlushJoinWord acc tables
2197+ , SkipStringLiteral tail rest
2198+ , ValidateJoinCondition rest tables
2199+ ) =>
2200+ ValidateJoinCondGo "'" tail acc tables
2201+
21942202-- End of string: flush final word
21952203else instance
21962204 ( Symbol.Append acc h acc'