@@ -291,7 +291,7 @@ pTreePath = do
291
291
-- Right [Node {rootLabel = SelectField {selField = ("*",[]), selAggregateFunction = Nothing, selAggregateCast = Nothing, selCast = Nothing, selAlias = Nothing}, subForest = []},Node {rootLabel = SelectRelation {selRelation = "client", selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selAggregateFunction = Nothing, selAggregateCast = Nothing, selCast = Nothing, selAlias = Nothing}, subForest = []},Node {rootLabel = SelectRelation {selRelation = "nested", selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selAggregateFunction = Nothing, selAggregateCast = Nothing, selCast = Nothing, selAlias = Nothing}, subForest = []}]}]}]
292
292
--
293
293
-- >>> P.parse pFieldForest "" "*,...client(*),other(*)"
294
- -- Right [Node {rootLabel = SelectField {selField = ("*",[]), selAggregateFunction = Nothing, selAggregateCast = Nothing, selCast = Nothing, selAlias = Nothing}, subForest = []},Node {rootLabel = SpreadRelation {selRelation = "client", selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selAggregateFunction = Nothing, selAggregateCast = Nothing, selCast = Nothing, selAlias = Nothing}, subForest = []}]},Node {rootLabel = SelectRelation {selRelation = "other", selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selAggregateFunction = Nothing, selAggregateCast = Nothing, selCast = Nothing, selAlias = Nothing}, subForest = []}]}]
294
+ -- Right [Node {rootLabel = SelectField {selField = ("*",[]), selAggregateFunction = Nothing, selAggregateCast = Nothing, selCast = Nothing, selAlias = Nothing}, subForest = []},Node {rootLabel = SpreadRelation {selRelation = "client", selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selAggregateFunction = Nothing, selAggregateCast = Nothing, selCast = Nothing, selAlias = Nothing}, subForest = []}]},Node {rootLabel = SelectRelation {selRelation = "other", selAlias = Nothing, selHint = Nothing, selJoinType = Nothing}, subForest = [Node {rootLabel = SelectField {selField = ("*",[]), selAggregateFunction = Nothing, selAggregateCast = Nothing, selCast = Nothing, selAlias = Nothing}, subForest = []}]}]
295
295
--
296
296
-- >>> P.parse pFieldForest "" ""
297
297
-- Right []
@@ -555,10 +555,13 @@ pFieldSelect = lexeme $ try (do
555
555
-- Parse spread relations in select
556
556
--
557
557
-- >>> P.parse pSpreadRelationSelect "" "...rel(*)"
558
- -- Right (SpreadRelation {selRelation = "rel", selHint = Nothing, selJoinType = Nothing})
558
+ -- Right (SpreadRelation {selRelation = "rel", selAlias = Nothing, selHint = Nothing, selJoinType = Nothing})
559
+ --
560
+ -- >>> P.parse pSpreadRelationSelect "" "...alias:rel(*)"
561
+ -- Right (SpreadRelation {selRelation = "rel", selAlias = Just "alias", selHint = Nothing, selJoinType = Nothing})
559
562
--
560
563
-- >>> P.parse pSpreadRelationSelect "" "...rel!hint!inner(*)"
561
- -- Right (SpreadRelation {selRelation = "rel", selHint = Just "hint", selJoinType = Just JTInner})
564
+ -- Right (SpreadRelation {selRelation = "rel", selAlias = Nothing, selHint = Just "hint", selJoinType = Just JTInner})
562
565
--
563
566
-- >>> P.parse pSpreadRelationSelect "" "rel(*)"
564
567
-- Left (line 1, column 1):
@@ -575,10 +578,11 @@ pFieldSelect = lexeme $ try (do
575
578
-- unexpected '>'
576
579
pSpreadRelationSelect :: Parser SelectItem
577
580
pSpreadRelationSelect = lexeme $ do
578
- name <- string " ..." >> pFieldName
581
+ alias <- string " ..." >> optionMaybe ( try(pFieldName <* aliasSeparator) )
582
+ name <- pFieldName
579
583
(hint, jType) <- pEmbedParams
580
584
try (void $ lookAhead (string " (" ))
581
- return $ SpreadRelation name hint jType
585
+ return $ SpreadRelation name alias hint jType
582
586
583
587
pEmbedParams :: Parser (Maybe Hint , Maybe JoinType )
584
588
pEmbedParams = do
0 commit comments