1. The documentation for the Sql Task is, I believe, inaccurate. It doesn't
mention that
the 'keepformat' attribute set to 'true' will eliminate the effect of the REM,
// and --
comments.
2. In any case, the attached diff should add the attribute 'commentchars' which
allow
the user to choose the single string of characters which constitute a line
commenter
when appearing at the head of the line. E.g.,
<sql commentchars="FOOBAR" ...
will make "FOOBAR" the only string found at the head of a line during processing
which comments out the line.
With this diff,
if (keepformat == false && (commentchars is_not_set))
then the Sql task will behave as it does currently, removing lines which start
with
REM, // or --
I have not fully tested this. If this is interesting to the Ant project, I will
procede
to test it (or modify it in light of critique), and subsequently submit a diff
which
includes the manual change. It seems a fairly obvious attribute for the Sql task
to present.
--
Jack J. Woehr # We have gone from the horse and buggy
Senior Consultant # to the moon rocket in one lifetime, but
Purematrix, Inc. # there has not been a corresponding moral
www.purematrix.com # growth in mankind. - Dwight D. Eisenhower
Index: src/main/org/apache/tools/ant/taskdefs/SQLExec.java
===================================================================
RCS file:
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/SQLExec.java,v
retrieving revision 1.67
diff -u -r1.67 SQLExec.java
--- src/main/org/apache/tools/ant/taskdefs/SQLExec.java 23 Feb 2004 19:28:23
-0000 1.67
+++ src/main/org/apache/tools/ant/taskdefs/SQLExec.java 14 Apr 2004 20:19:27
-0000
@@ -174,7 +174,14 @@
* @since Ant 1.6
*/
private boolean escapeProcessing = true;
-
+
+ /**
+ * User may chose the line comment characters
+ *
+ * @since Ant 1.7
+ */
+ private String commentChars = null;
+
/**
* Set the name of the SQL file to be run.
* Required unless statements are enclosed in the build file
@@ -313,6 +320,14 @@
public void setEscapeProcessing(boolean enable) {
escapeProcessing = enable;
}
+ /**
+ * Set line comment chars
+ * @param chars the string the user desires to comment out a line of SQL
+ * @since Ant 1.7
+ */
+ public void setCommentChars(String chars) {
+ commentChars = chars;
+ }
/**
* Load the sql file and then execute it
@@ -451,16 +466,23 @@
}
line = getProject().replaceProperties(line);
if (!keepformat) {
- if (line.startsWith("//")) {
- continue;
- }
- if (line.startsWith("--")) {
- continue;
+ if (commentChars == null) {
+ if (line.startsWith("//")) {
+ continue;
+ }
+ if (line.startsWith("--")) {
+ continue;
+ }
+ StringTokenizer st = new StringTokenizer(line);
+ if (st.hasMoreTokens()) {
+ String token = st.nextToken();
+ if ("REM".equalsIgnoreCase(token)) {
+ continue;
+ }
+ }
}
- StringTokenizer st = new StringTokenizer(line);
- if (st.hasMoreTokens()) {
- String token = st.nextToken();
- if ("REM".equalsIgnoreCase(token)) {
+ else{
+ if (line.startsWith(commentChars)) {
continue;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]