calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [1/2] incubator-calcite git commit: [CALCITE-803] Add MYSQL_ANSI Lexing policy.
Date Sat, 25 Jul 2015 02:13:28 GMT
Repository: incubator-calcite
Updated Branches:
  refs/heads/master 26a087745 -> 5cb95e644


[CALCITE-803] Add MYSQL_ANSI Lexing policy.


Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/e0a42301
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/e0a42301
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/e0a42301

Branch: refs/heads/master
Commit: e0a42301e5556685945ecbe2be83f93f10a1869f
Parents: 26a0877
Author: Jacques Nadeau <jacques@apache.org>
Authored: Fri Jul 24 09:53:02 2015 -0700
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Fri Jul 24 18:48:54 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/calcite/config/Lex.java     |  8 +++++
 .../java/org/apache/calcite/test/JdbcTest.java  | 34 ++++++++++++++++++++
 2 files changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/e0a42301/core/src/main/java/org/apache/calcite/config/Lex.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/config/Lex.java b/core/src/main/java/org/apache/calcite/config/Lex.java
index c492d1b..d5a50cb 100644
--- a/core/src/main/java/org/apache/calcite/config/Lex.java
+++ b/core/src/main/java/org/apache/calcite/config/Lex.java
@@ -36,6 +36,14 @@ public enum Lex {
    * Back-ticks allow identifiers to contain non-alphanumeric characters. */
   MYSQL(Quoting.BACK_TICK, Casing.UNCHANGED, Casing.UNCHANGED, false),
 
+  /** Lexical policy similar to MySQL with ANSI_QUOTES option enabled. (To be
+   * precise: MySQL on Windows; MySQL on Linux uses case-sensitive matching,
+   * like the Linux file system.) The case of identifiers is preserved whether
+   * or not they quoted; after which, identifiers are matched
+   * case-insensitively. Double quotes allow identifiers to contain
+   * non-alphanumeric characters. */
+  MYSQL_ANSI(Quoting.DOUBLE_QUOTE, Casing.UNCHANGED, Casing.UNCHANGED, false),
+
   /** Lexical policy similar to Microsoft SQL Server.
    * The case of identifiers is preserved whether or not they are quoted;
    * after which, identifiers are matched case-insensitively.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/e0a42301/core/src/test/java/org/apache/calcite/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index f365ab2..e466f39 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -5909,6 +5909,40 @@ public class JdbcTest {
             });
   }
 
+  /** Tests metadata for the MySQL ANSI lexical scheme. */
+  @Test public void testLexMySQLANSI() throws Exception {
+    CalciteAssert.that()
+        .with(Lex.MYSQL_ANSI)
+        .doWithConnection(
+            new Function<CalciteConnection, Void>() {
+              public Void apply(CalciteConnection connection) {
+                try {
+                  DatabaseMetaData metaData = connection.getMetaData();
+                  assertThat(metaData.getIdentifierQuoteString(), equalTo("\""));
+                  assertThat(metaData.supportsMixedCaseIdentifiers(),
+                      equalTo(false));
+                  assertThat(metaData.storesMixedCaseIdentifiers(),
+                      equalTo(true));
+                  assertThat(metaData.storesUpperCaseIdentifiers(),
+                      equalTo(false));
+                  assertThat(metaData.storesLowerCaseIdentifiers(),
+                      equalTo(false));
+                  assertThat(metaData.supportsMixedCaseQuotedIdentifiers(),
+                      equalTo(false));
+                  assertThat(metaData.storesMixedCaseQuotedIdentifiers(),
+                      equalTo(true));
+                  assertThat(metaData.storesUpperCaseIdentifiers(),
+                      equalTo(false));
+                  assertThat(metaData.storesLowerCaseQuotedIdentifiers(),
+                      equalTo(false));
+                  return null;
+                } catch (SQLException e) {
+                  throw new RuntimeException(e);
+                }
+              }
+            });
+  }
+
   /** Tests metadata for different the "SQL_SERVER" lexical scheme. */
   @Test public void testLexSqlServer() throws Exception {
     CalciteAssert.that()


Mime
View raw message