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: [email protected]
Reporter: [email protected]
QA Contact: [email protected]
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.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/