Skip to content

PostgreSQL with recursive fail with union in the final query #2050

@ohadpinch

Description

@ohadpinch
with recursive CHILDREN(UUID, PARENT_UUID) as
(
	(select GROUPING.GROUP_NODE.UUID, 
	 GROUPING.GROUP_NODE.PARENT_UUID
	 
	 from GROUPING.GROUP_NODE where GROUPING.GROUP_NODE.UUID = '1')

 union 
	(select op.UUID, op.PARENT_UUID
	 	 from GROUPING.GROUP_NODE as op join CHILDREN as c on op.PARENT_UUID = c.uuid)
)
(select * from CHILDREN )
union 
(select mn.UUID, mn.PARENT_UUID
 from GROUPING.MEMBER_NODE as mn, CHILDREN as c2 
 where (mn.parent_uuid = c2.uuid))

If we remove the parentheses ( ) from the "(select * from CHILDREN )" line it will WORK!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions