Skip to content

Commit

Permalink
Length of empty array should return 0, not NULL (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-circuithub committed Aug 16, 2023
1 parent 9e7a447 commit 8a468f5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Rel8/Type/Array.hs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@ upper a = Opaleye.FunExpr "array_lower" [a, one]


length :: Opaleye.PrimExpr -> Opaleye.PrimExpr
length a = Opaleye.FunExpr "array_length" [a, one]
length a = Opaleye.FunExpr "coalesce" [Opaleye.FunExpr "array_length" [a, one], zero]


one :: Opaleye.PrimExpr
one = Opaleye.ConstExpr (Opaleye.IntegerLit 1)
one = Opaleye.ConstExpr (Opaleye.IntegerLit 1)


zero :: Opaleye.PrimExpr
zero = Opaleye.ConstExpr (Opaleye.IntegerLit 0)

0 comments on commit 8a468f5

Please sign in to comment.