Skip to content

修复不使用`将sql的每一行包裹,导致原始sql有换行时生成的sql粘连问题 #586

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

Merged
merged 6 commits into from
Aug 6, 2025

Conversation

JiajieZeee
Copy link

例:

#pysql[("select user_id, user_name 
from user")]

生成的sql为 :

select user_id, user_namefrom user

修改后生成的sql为:

select user_id, user_name from user

before generate sql is :

select user_id, user_namefrom user

after generate sql is:

select user_id, user_name from user

select user_id, user_name \n from user

)], 生成的sql为 : select user_id, user_namefrom user,修改后生成的sql为:select user_id, user_name from user)
@zhuxiujia
Copy link
Member

有没有新增 更多场景的测试,貌似单元测试跑失败了

@Issues-translate-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Are there any new tests for more scenarios, it seems that the unit test failed

@Issues-translate-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I'll change it and run the test again

@JiajieZeee
Copy link
Author

已更改实现方法,在自己的项目里进行了测试,保留了自定义的sql格式,同时粘连问题也得到了解决

@Issues-translate-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The implementation method has been changed, tested in my own project, retained the custom SQL format, and the sticking problem has also been solved

@JiajieZeee JiajieZeee closed this Jul 29, 2025
@Issues-translate-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


If you have any questions, close it first

@JiajieZeee JiajieZeee reopened this Jul 29, 2025
@JiajieZeee
Copy link
Author

编译期的sql生成和运行时的动态拼接行为都已更改,动态sql的参数生成格式进行了更改,所以更改了一些测试用例,不影响语法执行

@Issues-translate-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The dynamic splicing behavior of SQL generation during the compilation period and the runtime have been changed. The parameter generation format of dynamic SQL has been changed, so some test cases have been changed, which does not affect syntax execution.

@zhuxiujia
Copy link
Member

codegen 也会影响html_sql 这块是不是也测试了的?

@Issues-translate-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Codegen will also affect the html_sql area. Is it also tested?

@JiajieZeee
Copy link
Author

JiajieZeee commented Aug 1, 2025

codegen 也会影响html_sql 这块是不是也测试了的?

是的,我梳理了一遍代码逻辑,pysql也转成了html_sql再执行的,所以再新加的测试用例里有一个就是测试html_sql的,对原来的逻辑没有任何影响,我在自己项目用复杂sql测了一遍

@Issues-translate-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


codegen will also affect the html_sql area. Has the code also been tested?

Yes, one of the newly added test cases is to test html_sql, which has no effect on the original logic. I used complex sql to test it in my project.

@zhuxiujia zhuxiujia merged commit 25b382e into rbatis:master Aug 6, 2025
6 checks passed
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

Successfully merging this pull request may close these issues.

3 participants