https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39259 Bug ID: 39259 Summary: SQL reports should allow Common Table Expressions Change sponsored?: --- Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: minor Priority: P5 - low Component: Reports Assignee: koha-bugs@lists.koha-community.org Reporter: schodkowy.omegi-0r@icloud.com QA Contact: testopia@bugs.koha-community.org Common table expression in MySQL is a syntax like this: WITH cte1 AS (SELECT a, b FROM table1), cte2 AS (SELECT c, d FROM table2) SELECT b, d FROM cte1 JOIN cte2 WHERE cte1.a = cte2.c; However, in Koha/Koha/Report.pm, there's func is_sql_valid: } elsif ( $sql !~ /^\s*SELECT\b\s*/i ) { push @errors, { queryerr => 'Missing SELECT' }; } It should be changed to SELECT|WITH, otherwise it won't allow these nice queries, instead having you to do an ugly workaround like this: SELECT * FROM ( WITH cte1 AS (SELECT a, b FROM table1), cte2 AS (SELECT c, d FROM table2) SELECT b, d FROM cte1 JOIN cte2 WHERE cte1.a = cte2.c ) AS dt; -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.