dataease / dataease/SQLBot

[BUG] 生成的SQL语句字段不存在

Open
#697 1 comment 0 reactions 2 assignees View on GitHub

@xuwei-fit2cloud is already working on this.

Since Dec 29, 2025.

bug
Dominant language
JavaScript
Stars
6.8k
Forks
882
Avg merge
4h 37m
Merged PRs (30d)
32

Description

SQLBot Version
1.4.0

Run Mode
Is it running in a Docker container or running from source code?
Docker container

Describe the bug
模型:Grok(换其他模型也出现过)
用户问题:新疆的塞浦路斯AAAA产品的提供商是谁?
生成SQL:
SELECT
c.CUSTOMER_NAME AS customer_name,
p.CUST_CURRENT_PROD AS product_name,
comp.COMPETITOR_NAME AS provider_name
FROM
sales.ai_cust_info c
JOIN sales.blade_region r ON c.PROVINCE = r.code
JOIN sales.ai_cust_prod cp ON c.ID = cp.CUST_ID
LEFT JOIN sales.ai_competitor comp ON FIND_IN_SET( comp.ID, cp.PROVIDER ) > 0
WHERE
c.CUSTOMER_NAME LIKE '%塞浦路斯%'
AND r.province_name LIKE '%新疆%'
AND cp.CUST_CURRENT_PROD LIKE '%AAAA%'
LIMIT 1000

查询字段 p.CUST_CURRENT_PROD ,就没有表的别名p,造成解析SQL报错。
之前还出现过表别名存在,查的字段在表里不存在。
小参数的模型还出现过,表别名和表名直接没有空格,反引号变成中文单引号,别名是保留字等问题。

是不是可以有个反思机制,对自己生成的SQL进行检查。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.