You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by ti...@apache.org on 2016/12/13 02:12:40 UTC
asterixdb git commit: ASTERIXDB-1749: fix breaking of lines using '\r'
Repository: asterixdb
Updated Branches:
refs/heads/master 7255c5d18 -> 3072ef35e
ASTERIXDB-1749: fix breaking of lines using '\r'
Change-Id: Ica5ce0b82f1d2c6f2033be2ce20bf56a563fb57b
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1382
Reviewed-by: Michael Blow <mb...@apache.org>
Tested-by: Michael Blow <mb...@apache.org>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/3072ef35
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/3072ef35
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/3072ef35
Branch: refs/heads/master
Commit: 3072ef35e0846883da03da59630ad1c9bd19f88e
Parents: 7255c5d
Author: Till Westmann <ti...@apache.org>
Authored: Sun Dec 11 17:59:29 2016 -0800
Committer: Till Westmann <ti...@apache.org>
Committed: Mon Dec 12 18:12:08 2016 -0800
----------------------------------------------------------------------
.../lang/common/parser/ScopeChecker.java | 2 +-
.../asterix/lang/sqlpp/parser/ParserTest.java | 54 ++++++++++++++++++++
2 files changed, 55 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3072ef35/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java
index 767eacb..1195d37 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java
@@ -51,7 +51,7 @@ public class ScopeChecker {
}
protected void setInput(String s) {
- inputLines = s.split("\n");
+ inputLines = s.split("\n|\r\n?");
}
// Forbidden scopes are used to disallow, in a limit clause, variables
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/3072ef35/asterixdb/asterix-lang-sqlpp/src/test/java/org/apache/asterix/lang/sqlpp/parser/ParserTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/test/java/org/apache/asterix/lang/sqlpp/parser/ParserTest.java b/asterixdb/asterix-lang-sqlpp/src/test/java/org/apache/asterix/lang/sqlpp/parser/ParserTest.java
new file mode 100644
index 0000000..27679a9
--- /dev/null
+++ b/asterixdb/asterix-lang-sqlpp/src/test/java/org/apache/asterix/lang/sqlpp/parser/ParserTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+package org.apache.asterix.lang.sqlpp.parser;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.lang.common.base.IParser;
+import org.apache.asterix.lang.common.base.IParserFactory;
+import org.junit.Test;
+
+public class ParserTest {
+
+ protected void testLineEnding(String query) throws Exception {
+ IParserFactory factory = new SqlppParserFactory();
+ IParser parser = factory.createParser(query);
+ try {
+ parser.parse();
+ } catch (AsterixException e) {
+ if (!e.getMessage().contains("Syntax error: In line 3")) {
+ throw new Exception("Unexpected error", e);
+ }
+ }
+ }
+
+ @Test
+ public void testCR() throws Exception {
+ testLineEnding("select\rvalue\r1");
+ }
+
+ @Test
+ public void testCRLF() throws Exception {
+ testLineEnding("select\r\nvalue\r\n1");
+ }
+
+ @Test
+ public void testLF() throws Exception {
+ testLineEnding("select\nvalue\n1");
+ }
+}