Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CYCLE #880

Open
MarkusWendorf opened this issue Feb 12, 2024 · 1 comment
Open

Support for CYCLE #880

MarkusWendorf opened this issue Feb 12, 2024 · 1 comment
Labels
api Related to library's API enhancement New feature or request postgres Related to PostgreSQL

Comments

@MarkusWendorf
Copy link
Contributor

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

@koskimas
Copy link
Member

This is not currently supported.

@igalklebanov igalklebanov added enhancement New feature or request api Related to library's API postgres Related to PostgreSQL labels Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to library's API enhancement New feature or request postgres Related to PostgreSQL
Projects
None yet
Development

No branches or pull requests

3 participants