Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一个字段设置了别名,对该字段设置组合之后,系统会将别名插入到原查询sql的order by参数中,因原表中无该字段,导致sql执行异常 #2973

Closed
ko6 opened this issue Sep 14, 2024 · 2 comments

Comments

@ko6
Copy link

ko6 commented Sep 14, 2024

版本号:

1.7.6

问题描述:

在报表中给字段添加排序后,报sql语法错误

错误日志&截图:

默认配置的sql:

SELECT
	COUNT(*) count,
	theme_name,
	base_theme_name
FROM
	(
	SELECT
		x.theme_name,
		(
		SELECT
			theme_name
		FROM
			(
			SELECT
				e.theme_name
			FROM
				BASE_INFO e
			WHERE
				e.THEME_CODE = '3'
			ORDER BY
				e.VERSION * 1 DESC )
		WHERE
			rownum = 1) base_theme_name,
	FROM
		BUSINESS_index x
	WHERE
		1 = 1
                )
GROUP BY
	theme_name,
	base_theme_name

给base_theme_name字段设置分组之后(纵向,排序为默认),实际执行的sql如下:

SELECT
	COUNT(1) total
FROM
	(
	SELECT
		COUNT(*) count,
		theme_name,
		base_theme_name
	FROM
		(
		SELECT
			x.theme_name,
			(
			SELECT
				theme_name
			FROM
				(
				SELECT
					e.theme_name
				FROM
					BASE_INFO e
				WHERE
					e.THEME_CODE = '3'
				ORDER BY
					base_theme_name,   --这里多了一个别名参数,但原表中不存在该字段
					e.VERSION * 1 DESC )
			WHERE
				rownum = 1) base_theme_name,
		FROM
			BUSINESS_index x
		WHERE
			1 = 1
                )
	GROUP BY
		theme_name,
		base_theme_name
 ) temp_count

在子查询中多了一个排序参数 base_theme_name,但这个参数是查询结果的别名,原表中并不存在这个字段,进而导致sql报错。

重现步骤:

友情提示(为了提高issue处理效率):

  • 积木报表是一款免费报表产品,功能免费源码不开放;
  • 未按格式要求发帖,会被直接删掉;
  • 请针对问题提供[报表设计配置或SQL脚本]或在官网制作报表示例并提供ID;
  • 针对不好重现的问题,请录制操作视频或详细的重现步骤;
@jeecgos
Copy link
Collaborator

jeecgos commented Sep 14, 2024

cr

@hoperunChen
Copy link

已修复,待新版本发布。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants