heavyai / heavyai-jdbc

A JDBC driver for connecting to an HeavyAI GPU database and running queries.
https://www.heavy.ai/
Other
9 stars 16 forks source link

DatabaseMetadata methods do not detect underscore '_' escaping #6

Open ssainz opened 6 years ago

ssainz commented 6 years ago

SQL uses underscore , '_', character in search pattern sentences that contain "LIKE" as a representation of any single character. Just like '%' is used to represent zero or more characters.

Ref: https://www.w3resource.com/sql/wildcards-like-operator/wildcards-underscore.php

In DatabaseMetadata methods (getColumns), many databases support these two wildcard characters (_, %).

In Mapd when fetching a table whose name contains '_' (e.g. 'customer_sales") , if the wildcard character is escaped (e.g. "customer\_sales"), the mapd driver will not find the table. This create trouble for reporting tools.

Mapd is not handling the escaped wildcard characters correctly in the DatabaseMetadata methods.

Also notice that MapD driver actually has implementation of DatabaseMetadata.getSearchStringEscape() to return "\" as well :) Which is mentioned in JDBC API: https://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getColumns(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)