tursodatabase/turso

CTE with same name as table rejects schema-qualified reference as circular

Open

#5,912 建立於 2026年3月12日

在 GitHub 查看
 (3 留言) (0 反應) (1 負責人)Rust (1,001 fork)github user discovery
compatibilitygood first issueparser

倉庫指標

Star
 (19,103 star)
PR 合併指標
 (PR 指標待抓取)

描述

Description

When a CTE has the same name as an existing table, the CTE body should be able to reference the original table using a schema-qualified name (main.t1). Turso incorrectly reports a circular reference.

Reproducer

CREATE TABLE t1(a INTEGER);
INSERT INTO t1 VALUES(1),(2),(3);

WITH t1 AS (SELECT a * 10 AS a FROM main.t1)
SELECT * FROM t1 ORDER BY a;
-- Turso: "circular reference: t1"
-- SQLite: 10, 20, 30

-- Works: CTE with different name
WITH cte AS (SELECT a * 10 AS a FROM main.t1)
SELECT * FROM cte ORDER BY a;
-- Both: 10, 20, 30

Per SQLite documentation: Schema-qualified table references should bypass CTE name resolution.


This issue brought to you by Mikaël and Claude Code.

貢獻者指南