@@ -1,5 +1,5 @@
2−Module: Squeal.PostgreSQL.Expression.SetOf
2+Module: Squeal.PostgreSQL.Expression.Set
3Description: Set returning functions
3Description: Set returning functions
4Copyright: (c) Eitan Chatav, 2019
4Copyright: (c) Eitan Chatav, 2019
5Maintainer: eitan@morphism.tech
5Maintainer: eitan@morphism.tech
@@ -20,17 +20,17 @@ Set returning functions
20 , TypeOperators
20 , TypeOperators
23−module Squeal.PostgreSQL.Expression.SetOf
23+module Squeal.PostgreSQL.Expression.Set
24 ( generateSeries
24 ( generateSeries
25 , generateSeriesStep
25 , generateSeriesStep
26 , generateSeriesTimestamp
26 , generateSeriesTimestamp
27− , SetOfFunction
27+ , SetFunction
28− , unsafeSetOfFunction
28+ , unsafeSetFunction
29− , SetOfFunctionDB
29+ , SetFunctionDB
30 , setOfFunction
30 , setOfFunction
31− , SetOfFunctionN
31+ , SetFunctionN
32− , unsafeSetOfFunctionN
32+ , unsafeSetFunctionN
33− , SetOfFunctionNDB
33+ , SetFunctionNDB
34 , setOfFunctionN
34 , setOfFunctionN
@@ -48,65 +48,65 @@ import Squeal.PostgreSQL.Schema
49A @RankNType@ for set returning functions with 1 argument.
49A @RankNType@ for set returning functions with 1 argument.
51−type SetOfFunction fun ty setof
51+type SetFunction fun ty row
52 = forall outer commons schemas params
52 = forall outer commons schemas params
53 . Expression outer commons 'Ungrouped schemas params '[] ty
53 . Expression outer commons 'Ungrouped schemas params '[] ty
54 -- ^ input
54 -- ^ input
55− -> FromClause outer commons schemas params '[fun ::: setof]
55+ -> FromClause outer commons schemas params '[fun ::: row]
56 -- ^ output
56 -- ^ output
58−type SetOfFunctionDB fun schemas ty setof
58+type SetFunctionDB fun schemas ty row
59 = forall outer commons params
59 = forall outer commons params
60 . Expression outer commons 'Ungrouped schemas params '[] ty
60 . Expression outer commons 'Ungrouped schemas params '[] ty
61 -- ^ input
61 -- ^ input
62− -> FromClause outer commons schemas params '[fun ::: setof]
62+ -> FromClause outer commons schemas params '[fun ::: row]
63 -- ^ output
63 -- ^ output
65-- | Escape hatch for a set returning function with 1 argument.
65-- | Escape hatch for a set returning function with 1 argument.
66−unsafeSetOfFunction
66+unsafeSetFunction
67− :: forall fun ty setof. KnownSymbol fun
67+ :: forall fun ty row. KnownSymbol fun
68− => SetOfFunction fun ty setof -- ^ set returning function
68+ => SetFunction fun ty row -- ^ set returning function
69−unsafeSetOfFunction x = UnsafeFromClause $
69+unsafeSetFunction x = UnsafeFromClause $
70 renderSymbol @fun <> parenthesized (renderSQL x)
70 renderSymbol @fun <> parenthesized (renderSQL x)
72setOfFunction
72setOfFunction
73 :: ( Has sch schemas schema
73 :: ( Has sch schemas schema
74− , Has fun schema ('Function ('[ty] :=> 'ReturnsTable setof)) )
74+ , Has fun schema ('Function ('[ty] :=> 'ReturnsTable row)) )
75 => QualifiedAlias sch fun
75 => QualifiedAlias sch fun
76− -> SetOfFunctionDB fun schemas ty setof
76+ -> SetFunctionDB fun schemas ty row
77−setOfFunction _ = unsafeSetOfFunction
77+setOfFunction _ = unsafeSetFunction
80A @RankNType@ for set returning functions with multiple argument.
80A @RankNType@ for set returning functions with multiple argument.
82−type SetOfFunctionN fun tys setof
82+type SetFunctionN fun tys row
83 = forall outer commons schemas params
83 = forall outer commons schemas params
84 . NP (Expression outer commons 'Ungrouped schemas params '[]) tys
84 . NP (Expression outer commons 'Ungrouped schemas params '[]) tys
85 -- ^ inputs
85 -- ^ inputs
86− -> FromClause outer commons schemas params '[fun ::: setof]
86+ -> FromClause outer commons schemas params '[fun ::: row]
87 -- ^ output
87 -- ^ output
89-- | Escape hatch for a set returning function with multiple argument.
89-- | Escape hatch for a set returning function with multiple argument.
90−unsafeSetOfFunctionN
90+unsafeSetFunctionN
91− :: forall fun tys setof. (SOP.SListI tys, KnownSymbol fun)
91+ :: forall fun tys row. (SOP.SListI tys, KnownSymbol fun)
92− => SetOfFunctionN fun tys setof -- ^ set returning function
92+ => SetFunctionN fun tys row -- ^ set returning function
93−unsafeSetOfFunctionN xs = UnsafeFromClause $
93+unsafeSetFunctionN xs = UnsafeFromClause $
94 renderSymbol @fun <> parenthesized (renderCommaSeparated renderSQL xs)
94 renderSymbol @fun <> parenthesized (renderCommaSeparated renderSQL xs)
96−type SetOfFunctionNDB fun schemas tys setof
96+type SetFunctionNDB fun schemas tys row
97 = forall outer commons params
97 = forall outer commons params
98 . NP (Expression outer commons 'Ungrouped schemas params '[]) tys
98 . NP (Expression outer commons 'Ungrouped schemas params '[]) tys
99 -- ^ inputs
99 -- ^ inputs
100− -> FromClause outer commons schemas params '[fun ::: setof]
100+ -> FromClause outer commons schemas params '[fun ::: row]
101 -- ^ output
101 -- ^ output
103setOfFunctionN
103setOfFunctionN
104 :: ( Has sch schemas schema
104 :: ( Has sch schemas schema
105− , Has fun schema ('Function (tys :=> 'ReturnsTable setof))
105+ , Has fun schema ('Function (tys :=> 'ReturnsTable row))
106 , SOP.SListI tys )
106 , SOP.SListI tys )
107 => QualifiedAlias sch fun
107 => QualifiedAlias sch fun
108− -> SetOfFunctionNDB fun schemas tys setof
108+ -> SetFunctionNDB fun schemas tys row
109−setOfFunctionN _ = unsafeSetOfFunctionN
109+setOfFunctionN _ = unsafeSetFunctionN
111{- | @generateSeries (start *: stop)@
111{- | @generateSeries (start *: stop)@
@@ -114,9 +114,9 @@ Generate a series of values, from @start@ to @stop@ with a step size of one
115generateSeries
115generateSeries
116 :: ty `In` '[ 'PGint4, 'PGint8, 'PGnumeric]
116 :: ty `In` '[ 'PGint4, 'PGint8, 'PGnumeric]
117− => SetOfFunctionN "generate_series" '[ null ty, null ty]
117+ => SetFunctionN "generate_series" '[ null ty, null ty]
118 '["generate_series" ::: null ty] -- ^ set returning function
118 '["generate_series" ::: null ty] -- ^ set returning function
119−generateSeries = unsafeSetOfFunctionN
119+generateSeries = unsafeSetFunctionN
121{- | @generateSeries (start :* stop *: step)@
121{- | @generateSeries (start :* stop *: step)@
@@ -124,9 +124,9 @@ Generate a series of values, from @start@ to @stop@ with a step size of @step@
125generateSeriesStep
125generateSeriesStep
126 :: ty `In` '[ 'PGint4, 'PGint8, 'PGnumeric]
126 :: ty `In` '[ 'PGint4, 'PGint8, 'PGnumeric]
127− => SetOfFunctionN "generate_series" '[null ty, null ty, null ty]
127+ => SetFunctionN "generate_series" '[null ty, null ty, null ty]
128 '["generate_series" ::: null ty] -- ^ set returning function
128 '["generate_series" ::: null ty] -- ^ set returning function
129−generateSeriesStep = unsafeSetOfFunctionN
129+generateSeriesStep = unsafeSetFunctionN
131{- | @generateSeries (start :* stop *: step)@
131{- | @generateSeries (start :* stop *: step)@
@@ -134,6 +134,6 @@ Generate a series of values, from @start@ to @stop@ with a step size of @step@
135generateSeriesTimestamp
135generateSeriesTimestamp
136 :: ty `In` '[ 'PGtimestamp, 'PGtimestamptz]
136 :: ty `In` '[ 'PGtimestamp, 'PGtimestamptz]
137− => SetOfFunctionN "generate_series" '[null ty, null ty, null 'PGinterval]
137+ => SetFunctionN "generate_series" '[null ty, null ty, null 'PGinterval]
138 '["generate_series" ::: null ty] -- ^ set returning function
138 '["generate_series" ::: null ty] -- ^ set returning function
139−generateSeriesTimestamp = unsafeSetOfFunctionN
139+generateSeriesTimestamp = unsafeSetFunctionN