Component docs - fixed issue with sql not including all of them

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5e130000
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5e130000
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5e130000

Branch: refs/heads/camel-2.16.x
Commit: 5e13000029d57913510e72d8f515d4e4eddc77ae
Parents: fbb31ad
Author: Claus Ibsen <davscl...@apache.org>
Authored: Sat Jan 2 23:12:49 2016 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Sat Jan 2 23:16:05 2016 +0100

----------------------------------------------------------------------
 .../camel/component/sql/DefaultSqlEndpoint.java  | 19 +++++++++++++++++--
 .../apache/camel/component/sql/SqlComponent.java |  3 ++-
 .../camel/component/sql/SqlDataSourceTest.java   |  2 +-
 3 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5e130000/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlEndpoint.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlEndpoint.java
index 0f7d4ce..67e8f23 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlEndpoint.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlEndpoint.java
@@ -85,7 +85,7 @@ public abstract class DefaultSqlEndpoint extends 
DefaultPollingEndpoint {
     private boolean alwaysPopulateStatement;
     @UriParam(defaultValue = ",",
             description = "The separator to use when parameter values is taken 
from message body (if the body is a String type), to be inserted at # 
placeholders."
-            + "Notice if you use named parameters, then a Map type is used 
instead. The default value is ,")
+            + "Notice if you use named parameters, then a Map type is used 
instead. The default value is comma")
     private char separator = ',';
     @UriParam(defaultValue = "SelectList", description = "Make the output of 
consumer or producer to SelectList as List of Map, or SelectOne as single Java 
object in the following way:"
             + "a) If the query has only single column, then that JDBC Column 
object is returned. (such as SELECT COUNT( * ) FROM PROJECT will return a Long 
object."
@@ -107,6 +107,9 @@ public abstract class DefaultSqlEndpoint extends 
DefaultPollingEndpoint {
     private String outputHeader;
     @UriParam(label = "producer", description = "Whether to use the message 
body as the SQL and then headers for parameters. If this option is enabled then 
the SQL in the uri is not used.")
     private boolean useMessageBodyForSql;
+    @UriParam(label = "advanced", defaultValue = "#", description = "Specifies 
a character that will be replaced to ? in SQL query."
+            + " Notice, that it is simple String.replaceAll() operation and no 
SQL parsing is involved (quoted strings will also change).")
+    private String placeholder = "#";
 
     public DefaultSqlEndpoint() {
     }
@@ -249,7 +252,7 @@ public abstract class DefaultSqlEndpoint extends 
DefaultPollingEndpoint {
      * The separator to use when parameter values is taken from message body 
(if the body is a String type), to be inserted at # placeholders.
      * Notice if you use named parameters, then a Map type is used instead.
      * <p/>
-     * The default value is ,
+     * The default value is comma.
      */
     public void setSeparator(char separator) {
         this.separator = separator;
@@ -400,6 +403,18 @@ public abstract class DefaultSqlEndpoint extends 
DefaultPollingEndpoint {
         this.breakBatchOnConsumeFail = breakBatchOnConsumeFail;
     }
 
+    public String getPlaceholder() {
+        return placeholder;
+    }
+
+    /**
+     * Specifies a character that will be replaced to ? in SQL query.
+     * Notice, that it is simple String.replaceAll() operation and no SQL 
parsing is involved (quoted strings will also change).
+     */
+    public void setPlaceholder(String placeholder) {
+        this.placeholder = placeholder;
+    }
+
     @SuppressWarnings("unchecked")
     public List<?> queryForList(ResultSet rs, boolean allowMapToClass) throws 
SQLException {
         if (allowMapToClass && outputClass != null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/5e130000/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
index 7236392..0446520 100755
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
@@ -75,7 +75,7 @@ public class SqlComponent extends UriEndpointComponent {
         }
 
         String parameterPlaceholderSubstitute = 
getAndRemoveParameter(parameters, "placeholder", String.class, "#");
-        
+
         JdbcTemplate jdbcTemplate = new JdbcTemplate(target);
         IntrospectionSupport.setProperties(jdbcTemplate, parameters, 
"template.");
 
@@ -104,6 +104,7 @@ public class SqlComponent extends UriEndpointComponent {
         }
 
         SqlEndpoint endpoint = new SqlEndpoint(uri, this, jdbcTemplate, query);
+        endpoint.setPlaceholder(parameterPlaceholderSubstitute);
         endpoint.setOnConsume(onConsume);
         endpoint.setOnConsumeFailed(onConsumeFailed);
         endpoint.setOnConsumeBatchComplete(onConsumeBatchComplete);

http://git-wip-us.apache.org/repos/asf/camel/blob/5e130000/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceTest.java
 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceTest.java
index 4ca67c1..6a08c24 100644
--- 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceTest.java
+++ 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlDataSourceTest.java
@@ -78,7 +78,7 @@ public class SqlDataSourceTest extends CamelTestSupport {
         return new RouteBuilder() {
             public void configure() {
                 from("direct:simple")
-                    .to("sql:select * from projects where license = # order by 
id?dataSource=dataSource")
+                    .to("sql:select * from projects where license = # order by 
id?dataSource=#dataSource")
                     .to("mock:result");
             }
         };

Reply via email to