Skip to content

Commit 94e5373

Browse files
committed
Fix paths in array_agg
1 parent 97d6724 commit 94e5373

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Droplet/Language/Internal/Function.purs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ class ToArrayAgg (f ∷ Type) (fields ∷ Row Type) (t ∷ Type) | f → fields
6868

6969
instance (Cons name t e fields, UnwrapDefinition t u) ToArrayAgg (Proxy name) fields u
7070

71-
instance (Cons name t e fields, UnwrapDefinition t u) ToArrayAgg (Path alias name) fields u
71+
instance
72+
( AppendPath alias name fullPath
73+
, Cons fullPath t e fields
74+
, UnwrapDefinition t u
75+
)
76+
ToArrayAgg (Path alias name) fields u
7277

7378
-- | Function arguments must match input type
7479
class MatchArgumentList (inputType) (argsType) (fieldsRow Type)

src/Droplet/Language/Internal/Syntax.purs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,10 @@ instance
737737
ToArrayAgg (OrderBy (Proxy name) (Proxy otherName)) fields w
738738

739739
instance
740-
( Cons name t e fields
741-
, Cons otherName v r fields
740+
( AppendPath alias name fullPath
741+
, Cons fullPath t e fields
742+
, AppendPath otherAlias otherName otherFullPath
743+
, Cons otherFullPath v r fields
742744
, UnwrapDefinition v w
743745
)
744746
ToArrayAgg (OrderBy (Path alias name) (Path otherAlias otherName)) fields w

test/Function.purs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Test.Function where
22

3-
import Prelude
3+
import Prelude hiding (join)
44

55
import Data.BigInt as DB
66
import Data.Maybe (Maybe(..))
@@ -89,6 +89,10 @@ tests = TS.describe "functions" do
8989
let q = select (array_agg (u ... id) # as u) # from (users # as u)
9090
TM.notParameterized """SELECT array_agg("u"."id") AS "u" FROM "users" AS "u"""" $ DLIQ.buildQuery q
9191
TM.result q [ { u: Just [1, 2] } ]
92+
TS.it "joined source" do
93+
let q = select (array_agg (u ... id) # as u) # from (join (users # as u) (messages # as t) # on (u ... id .=. t ... id))
94+
TM.notParameterized """SELECT array_agg("u"."id") AS "u" FROM "users" AS "u" INNER JOIN "messages" AS "t" ON "u"."id" = "t"."id"""" $ DLIQ.buildQuery q
95+
TM.result q [ { u: Just [1, 2] } ]
9296
TS.describe "order by" do
9397
TS.it "field" do
9498
let q = select (array_agg (id # orderBy id) # as u) # from users

0 commit comments

Comments
 (0)