Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/org/apache/ibatis/parsing/XNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ public String getStringBody(String def) {
}
}

public String getStringBody(String def, boolean removeBlankLines){
if(body == null){
return def;
} else {
if (removeBlankLines) {
return body.replaceAll("(\\n|\\r\\n)", " ").replaceAll("\\t"," ");
} else {
return body;
}
}
}

public Boolean getBooleanBody() {
return getBooleanBody(null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2015 the original author or authors.
* Copyright 2009-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ public SqlSource parseScriptNode() {
}

List<SqlNode> parseDynamicTags(XNode node) {
final boolean compactedSQL = configuration.isCompactedSQL();
List<SqlNode> contents = new ArrayList<SqlNode>();
NodeList children = node.getNode().getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
XNode child = node.newXNode(children.item(i));
if (child.getNode().getNodeType() == Node.CDATA_SECTION_NODE || child.getNode().getNodeType() == Node.TEXT_NODE) {
String data = child.getStringBody("");
String data = child.getStringBody("", compactedSQL);
TextSqlNode textSqlNode = new TextSqlNode(data);
if (textSqlNode.isDynamic()) {
contents.add(textSqlNode);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/apache/ibatis/session/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public class Configuration {
protected boolean callSettersOnNulls;
protected boolean useActualParamName = true;
protected boolean returnInstanceForEmptyRow;
protected boolean compactedSQL = false;

protected String logPrefix;
protected Class <? extends Log> logImpl;
Expand Down Expand Up @@ -259,6 +260,14 @@ public void setReturnInstanceForEmptyRow(boolean returnEmptyInstance) {
this.returnInstanceForEmptyRow = returnEmptyInstance;
}

public boolean isCompactedSQL() {
return compactedSQL;
}

public void setCompactedSQL(boolean compactedSQL) {
this.compactedSQL = compactedSQL;
}

public String getDatabaseId() {
return databaseId;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2015 the original author or authors.
* Copyright 2009-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down