This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-2.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-2.x by this push: new d156701 CAMEL-13344: camel-sql - stored procedure loaded from file/classpath should skip comment lines d156701 is described below commit d1567013ba3b52ab9ff191bcf8ca713b11255c6a Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Mar 20 06:25:49 2019 +0100 CAMEL-13344: camel-sql - stored procedure loaded from file/classpath should skip comment lines --- .../java/org/apache/camel/component/sql/SqlHelper.java | 11 +++++++++++ .../camel-sql/src/test/resources/sql/selectStored.sql | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlHelper.java b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlHelper.java index f935b37..75d2c6a 100644 --- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlHelper.java +++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlHelper.java @@ -18,6 +18,7 @@ package org.apache.camel.component.sql; import java.io.IOException; import java.io.InputStream; +import java.util.StringJoiner; import org.apache.camel.CamelContext; import org.apache.camel.NoTypeConversionAvailableException; @@ -39,6 +40,16 @@ public final class SqlHelper { if (placeholder != null) { answer = answer.replaceAll(placeholder, "?"); } + // skip lines with comments + StringJoiner sj = new StringJoiner("\n"); + String[] lines = answer.split("\n"); + for (String line : lines) { + String trim = line.trim(); + if (!trim.isEmpty() && !trim.startsWith("--")) { + sj.add(line); + } + } + answer = sj.toString(); } return answer; } diff --git a/components/camel-sql/src/test/resources/sql/selectStored.sql b/components/camel-sql/src/test/resources/sql/selectStored.sql index 7430b7f..5e47353 100644 --- a/components/camel-sql/src/test/resources/sql/selectStored.sql +++ b/components/camel-sql/src/test/resources/sql/selectStored.sql @@ -1,3 +1,20 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + SUBNUMBERS( INTEGER ${headers.num1} , INTEGER ${headers.num2} ,