kysely icon indicating copy to clipboard operation
kysely copied to clipboard

Support for CYCLE

Open MarkusWendorf opened this issue 1 year ago • 4 comments

Hello,

I was wondering if it is possible to express the following query with Kysely:

WITH RECURSIVE blok_search AS (
    -- Base case
    SELECT *, 1 AS Depth
    FROM bloks
    WHERE id = 1
    
    UNION ALL
    
    -- Recursive case
    SELECT i.*, c.Depth + 1
    FROM bloks i
    JOIN blok_search c ON 
    	c.Depth < 3 AND
    	(
	        (c.type = 'headline' AND c."link" = i.id) OR
	        (c.type = 'headline' AND c."link2" = i.id) OR
	        (c.type = 'child' AND c.link = i.link)
        )
) CYCLE id SET is_cycle USING path

SELECT * FROM blok_search WHERE is_cycle = FALSE;

This is what I got so far: Playground

I tried it with modifyEnd but could not place it at the right position:

WITH RECURSIVE
  "blok_search" AS (...
) CYCLE id SET is_cycle USING path

Thank you

MarkusWendorf avatar Feb 12 '24 13:02 MarkusWendorf

This is not currently supported.

koskimas avatar Mar 24 '24 06:03 koskimas