druid 解析select into出错

bt1cpqcv  于 2021-11-27  发布在  Java
关注(0)|答案(1)|浏览(358)

正常sql
SELECT CASE WHEN da2.area_id IS NULL THEN 0 ELSE da1.area_id END AS country, CASE da3.area_id IS NULL WHEN 1 THEN CASE da2.area_id IS NULL WHEN 1 THEN 0 ELSE da1.area_id END ELSE da2.area_id END AS city, IFNULL(da3.area_id, IFNULL(da2.area_id, da1.area_id)) AS province INTO @country, @city, @province FROM dbn_area da1 LEFT JOIN dbn_area da2 ON da1.parent_id = da2.area_id LEFT JOIN dbn_area da3 ON da2.parent_id = da3.area_id WHERE da1.area_id = 5342;
解析为
SELECT CASE WHEN da2.area_id IS NULL THEN 0 ELSE da1.area_id END AS country , CASE da3.area_id IS NULL WHEN 1 THEN CASE da2.area_id IS NULL WHEN 1 THEN 0 ELSE da1.area_id END ELSE da2.area_id END AS city , IFNULL(da3.area_id, IFNULL(da2.area_id, da1.area_id)) AS province INTO (@country, @city, @province) FROM dbn_area da1 LEFT JOIN dbn_area da2 ON da1.parent_id = da2.area_id LEFT JOIN dbn_area da3 ON da2.parent_id = da3.area_id WHERE da1.area_id = 5342;
into子句加了对括号,执行报错

s8vozzvw

s8vozzvw1#

原始语句                                                 解析后
INTO @country, @city, @province  --> INTO (@country, @city, @province)

代码在这里
https://github.com/alibaba/druid/blob/master/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java#L3254

相关问题