Skip to content

Commit

Permalink
Fixed #1000 SQL exception in COPY statement when the DELIMITER is set…
Browse files Browse the repository at this point in the history
… to a semicolon
  • Loading branch information
Axel Fontaine committed Dec 29, 2015
1 parent c476784 commit d657615
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Expand Up @@ -123,7 +123,7 @@ public boolean isTerminated() {
*/
public SqlStatement getSqlStatement() {
String sql = statement.toString();
return new SqlStatement(lineNumber, sql, isPgCopy());
return new SqlStatement(lineNumber, sql, isPgCopyFromStdIn());
}

/**
Expand All @@ -142,7 +142,7 @@ public Delimiter extractNewDelimiterFromLine(String line) {
*
* @return {@code true} if it is, {@code false} if not.
*/
public boolean isPgCopy() {
public boolean isPgCopyFromStdIn() {
return false;
}

Expand Down
@@ -1,12 +1,12 @@
/**
* Copyright 2010-2015 Axel Fontaine
* <p/>
*
* Licensed 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
*
* 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.
Expand Down
Expand Up @@ -84,7 +84,7 @@ protected Delimiter changeDelimiterIfNecessary(String line, Delimiter delimiter)
}

@Override
public boolean isPgCopy() {
public boolean isPgCopyFromStdIn() {
return pgCopy;
}
}
Expand Up @@ -68,6 +68,15 @@ public void ts() {
assertEquals(line, statementBuilder.getSqlStatement().getSql());
}

@Test
public void copy() {
String line = "COPY CSV_FILES FROM '/path/to/filename.csv' DELIMITER ';' CSV HEADER";
statementBuilder.addLine(line + ";\n");
assertTrue(statementBuilder.isTerminated());
assertFalse(statementBuilder.isPgCopyFromStdIn());
assertEquals(line, statementBuilder.getSqlStatement().getSql());
}

@Test
public void multilineStringLiteralWithSemicolons() {
String sqlScriptSource = "INSERT INTO address VALUES (1, '1. first;\n"
Expand Down

0 comments on commit d657615

Please sign in to comment.