From 072e7a5d137ba494fd447a683ae69268fe360966 Mon Sep 17 00:00:00 2001 From: dimgigov Date: Thu, 21 May 2026 09:44:32 +0300 Subject: [PATCH] test(join): add test for duplicate columns in SELECT * Verify that JOIN with overlapping column names preserves both left (bare) and right (qualified) values. --- tests/join_tests.nim | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/join_tests.nim b/tests/join_tests.nim index 8152c87..93414e1 100644 --- a/tests/join_tests.nim +++ b/tests/join_tests.nim @@ -107,3 +107,15 @@ suite "JOIN execution": let r = execSql(ctx, "SELECT u.name, x.total FROM users u CROSS JOIN LATERAL (SELECT o.total FROM orders o WHERE o.user_id = u.id) AS x") check r.rows.len == 2 # Alice has 2 orders, Bob has 0 + + test "SELECT * with duplicate column names preserves both sides": + let r = execSql(ctx, "SELECT * FROM users u JOIN orders o ON u.id = o.user_id") + check r.rows.len == 2 + # Both tables have 'id' — left value should be accessible bare, + # right value should be accessible via alias. + check r.rows[0]["id"] == "1" # users.id (left side wins bare name) + check r.rows[0]["o.id"] == "10" # orders.id (qualified) + check r.rows[0]["name"] == "Alice" + check r.rows[0]["total"] == "99.5" + check "o.id" in r.columns + check "u.id" notin r.columns # left id stays bare, not duplicated as u.id