Browse Source

Merge branch '1.9.x'

master
Stefan Bodewig 8 years ago
parent
commit
5c9767039b
5 changed files with 33 additions and 4 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +7
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +7
    -0
      manual/Tasks/sql.html
  5. +14
    -4
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java

+ 1
- 0
CONTRIBUTORS View File

@@ -125,6 +125,7 @@ Erik Hatcher
Erik Langenbach
Erik Meade
Ernst de Haan
Francesco Steccanella
Frank Harnack
Frank Somers
Frank Zeyda


+ 7
- 0
WHATSNEW View File

@@ -1,6 +1,13 @@
Changes from Ant 1.10.1 TO Ant 1.10.2
=====================================

Other changes:
--------------

* Added forceCsvQuoteChar option to <csv> task. When enabled the
values always get quoted.
Github Pull Request #32

Changes from Ant 1.10.0 TO Ant 1.10.1
=====================================



+ 4
- 0
contributors.xml View File

@@ -523,6 +523,10 @@
<first>Ernst</first>
<last>de Haan</last>
</name>
<name>
<first>Francesco</first>
<last>Steccanella</last>
</name>
<name>
<first>Frank</first>
<last>Harnack</last>


+ 7
- 0
manual/Tasks/sql.html View File

@@ -262,6 +262,13 @@ and <b>abort</b> execution and transaction and fail task.</p>
ever occurs)</td>
</tr>

<tr>
<td width="12%" valign="top">forceCsvQuoteChar</td>
<td width="78%" valign="top">If true, quoting always occurs</td>
<td width="10%" valign="top">No, default is not set (i.e. quoting
occurs only where needed)</td>
</tr>

<tr>
<td valign="top">errorproperty</td>
<td valign="top">The name of a property to set in the event of an


+ 14
- 4
src/main/org/apache/tools/ant/taskdefs/SQLExec.java View File

@@ -273,6 +273,11 @@ public class SQLExec extends JDBCTask {
*/
private String rowCountProperty = null;

/**
* The name of the property to force the csv quote character
*/
private boolean forceCsvQuoteChar = false;

/**
* Set the name of the SQL file to be run.
* Required unless statements are enclosed in the build file
@@ -586,6 +591,13 @@ public class SQLExec extends JDBCTask {
this.rowCountProperty = rowCountProperty;
}

/**
* Force the csv quote character
*/
public void setForceCsvQuoteChar(boolean forceCsvQuoteChar) {
this.forceCsvQuoteChar = forceCsvQuoteChar;
}

/**
* Load the sql file and then execute it
* @throws BuildException on error.
@@ -859,7 +871,7 @@ public class SQLExec extends JDBCTask {
int columnCount = md.getColumnCount();
if (columnCount > 0) {
if (showheaders) {
out.print(md.getColumnName(1));
out.print(maybeQuote(md.getColumnName(1)));
for (int col = 2; col <= columnCount; col++) {
out.print(csvColumnSep);
out.print(maybeQuote(md.getColumnName(col)));
@@ -893,9 +905,7 @@ public class SQLExec extends JDBCTask {
}

private String maybeQuote(String s) {
if (csvQuoteChar == null || s == null
|| (s.indexOf(csvColumnSep) == -1 && s.indexOf(csvQuoteChar) == -1)
) {
if (csvQuoteChar == null || s == null || (!forceCsvQuoteChar && s.indexOf(csvColumnSep) == -1 && s.indexOf(csvQuoteChar) == -1)) {
return s;
}
StringBuffer sb = new StringBuffer(csvQuoteChar);


Loading…
Cancel
Save