Mybatis-3: Remove blank lines in SQL

Created on 2 Nov 2017  ·  17Comments  ·  Source: mybatis/mybatis-3

Question:
MyBatis build SQL include many blank lines from XML.
The blank lines is unnecessary.

https://issues.apache.org/jira/browse/IBATIS-143

class XMLScriptBuilder
Let XNode replace '\n' or "\r\n" to ' ' .
I want the feature can be configurable.

enhancement

Most helpful comment

Hi @zhaoxi1988 , contributing welcome!! :D

All 17 comments

Hi @zhaoxi1988 , contributing welcome!! :D

Oh. I accept it.

By the way.
Why do not mybatis's package name 'org.apache.mybatis' ?

@zhaoxi1988 Is the problem solved?

@George5814 Still not solved...I busy on mybatis UnitTest...

@George5814
My idea:
1.add in org.apache.ibatis.session.Configuration
2.push configuration down , let SqlSourceBuilder trim '\r|\n' or replace('\r|\n', ' ')

单元测试在IntelliJ上, 只安装JDK8有点尴尬...

I'm wondering why this feature request gets many votes.
Is there any actual harm caused by the extra blank lines?

This is to delete the extra whitespace produced by the dynamic tags, not to beautify the SQL.
Improve readability.

@George5814
Recent versions of MyBatis remove blank lines when printing the log, so where do you see the SQLs with blank lines?

@harawata Because the Database Server logging SQL is not convenient.
Then the next requirement is that tracing SQL instance in MyBatis , e.g.