asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Till Westmann (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: ASTERIXDB-1749: fix breaking of lines using '\r'
Date Mon, 12 Dec 2016 02:00:16 GMT
Till Westmann has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1382

Change subject: ASTERIXDB-1749: fix breaking of lines using '\r'
......................................................................

ASTERIXDB-1749: fix breaking of lines using '\r'

Change-Id: Ica5ce0b82f1d2c6f2033be2ce20bf56a563fb57b
---
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java
A asterixdb/asterix-lang-sqlpp/src/test/java/org/apache/asterix/lang/sqlpp/parser/ParserTest.java
2 files changed, 55 insertions(+), 1 deletion(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/82/1382/1

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 @@
     }
 
     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
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");
+    }
+}

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1382
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica5ce0b82f1d2c6f2033be2ce20bf56a563fb57b
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Till Westmann <tillw@apache.org>

Mime
View raw message