@@ -24,8 +24,8 @@ import Rel8.Expr.Aggregate ( listAggExpr, nonEmptyAggExpr )
24import Rel8.Expr.Opaleye ( mapPrimExpr )
24import Rel8.Expr.Opaleye ( mapPrimExpr )
25import Rel8.Query ( Query )
25import Rel8.Query ( Query )
26import Rel8.Query.Aggregate ( aggregate )
26import Rel8.Query.Aggregate ( aggregate )
27−import Rel8.Query.Evaluate ( rebind )
28import Rel8.Query.Maybe ( optional )
27import Rel8.Query.Maybe ( optional )
28+import Rel8.Query.Rebind ( rebind )
29import Rel8.Schema.HTable.Vectorize ( hunvectorize )
29import Rel8.Schema.HTable.Vectorize ( hunvectorize )
30import Rel8.Schema.Null ( Sql, Unnullify )
30import Rel8.Schema.Null ( Sql, Unnullify )
31import Rel8.Schema.Spec ( Spec( Spec, info ) )
31import Rel8.Schema.Spec ( Spec( Spec, info ) )
@@ -85,8 +85,9 @@ someExpr = aggregate . fmap nonEmptyAggExpr
86-- @catListTable@ is an inverse to 'many'.
86-- @catListTable@ is an inverse to 'many'.
87catListTable :: Table Expr a => ListTable Expr a -> Query a
87catListTable :: Table Expr a => ListTable Expr a -> Query a
88+catListTable (ListTable as) =
88−catListTable (ListTable as) = rebind $ fromColumns $ runIdentity $
89+ rebind "unnest" $ fromColumns $ runIdentity $
89− hunvectorize (\Spec {info} -> pure . sunnest info) as
90+ hunvectorize (\Spec {info} -> pure . sunnest info) as
92-- | Expand a 'NonEmptyTable' into a 'Query', where each row in the query is an
93-- | Expand a 'NonEmptyTable' into a 'Query', where each row in the query is an
@@ -94,8 +95,9 @@ catListTable (ListTable as) = rebind $ fromColumns $ runIdentity $
95-- @catNonEmptyTable@ is an inverse to 'some'.
96-- @catNonEmptyTable@ is an inverse to 'some'.
96catNonEmptyTable :: Table Expr a => NonEmptyTable Expr a -> Query a
97catNonEmptyTable :: Table Expr a => NonEmptyTable Expr a -> Query a
97−catNonEmptyTable (NonEmptyTable as) = rebind $ fromColumns $ runIdentity $
98+catNonEmptyTable (NonEmptyTable as) =
99+ rebind "unnest" $ fromColumns $ runIdentity $
98− hunvectorize (\Spec {info} -> pure . sunnest info) as
100+ hunvectorize (\Spec {info} -> pure . sunnest info) as
101-- | Expand an expression that contains a list into a 'Query', where each row
103-- | Expand an expression that contains a list into a 'Query', where each row
@@ -103,7 +105,7 @@ catNonEmptyTable (NonEmptyTable as) = rebind $ fromColumns $ runIdentity $
104-- @catList@ is an inverse to 'manyExpr'.
106-- @catList@ is an inverse to 'manyExpr'.
105catList :: Sql DBType a => Expr [a] -> Query (Expr a)
107catList :: Sql DBType a => Expr [a] -> Query (Expr a)
106−catList = rebind . sunnest typeInformation
108+catList = rebind "unnest" . sunnest typeInformation
109-- | Expand an expression that contains a non-empty list into a 'Query', where
111-- | Expand an expression that contains a non-empty list into a 'Query', where
@@ -111,7 +113,7 @@ catList = rebind . sunnest typeInformation
112-- @catNonEmpty@ is an inverse to 'someExpr'.
114-- @catNonEmpty@ is an inverse to 'someExpr'.
113catNonEmpty :: Sql DBType a => Expr (NonEmpty a) -> Query (Expr a)
115catNonEmpty :: Sql DBType a => Expr (NonEmpty a) -> Query (Expr a)
114−catNonEmpty = rebind . sunnest typeInformation
116+catNonEmpty = rebind "unnest" . sunnest typeInformation
117sunnest :: TypeInformation (Unnullify a) -> Expr (list a) -> Expr a
119sunnest :: TypeInformation (Unnullify a) -> Expr (list a) -> Expr a