From afc94cd3be0a90db9db8e3050e00d916b6ebc2a5 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Sun, 18 May 2025 12:51:52 +0300 Subject: [PATCH] Add basic select distinct TCL test --- testing/subquery.test | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testing/subquery.test b/testing/subquery.test index 3eb2e3326..98ecec001 100644 --- a/testing/subquery.test +++ b/testing/subquery.test @@ -411,3 +411,25 @@ do_execsql_test subquery-ignore-unused-cte { sub as (select first_name from users where first_name = 'Jamie' limit 1) select * from sub; } {Jamie} + +# Test verifying that select distinct works (distinct ages are 1-100) +do_execsql_test subquery-count-distinct-age { + select count(1) from (select distinct age from users); +} {100} + +# Test verifying that select distinct works for multiple columns, and across joins +do_execsql_test subquery-count-distinct { + select count(1) from ( + select distinct first_name, name + from users u join products p + where u.id < 100 + ); +} {902} + +do_execsql_test subquery-count-all { + select count(1) from ( + select first_name, name + from users u join products p + where u.id < 100 + ); +} {1089}