You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Igor Rudyak (JIRA)" <ji...@apache.org> on 2016/08/28 23:07:21 UTC

[jira] [Created] (IGNITE-3792) Wrap table and column names with escape characters in generated H2 SQL queries

Igor Rudyak created IGNITE-3792:
-----------------------------------

             Summary: Wrap table and column names with escape characters in generated H2 SQL queries
                 Key: IGNITE-3792
                 URL: https://issues.apache.org/jira/browse/IGNITE-3792
             Project: Ignite
          Issue Type: Bug
          Components: jdbc-driver, odbc, SQL
            Reporter: Igor Rudyak


Sometimes user can specify SQL reserved word as a class name (or as a class member name) for objects stored in Ignite cache. In such cases current implementation will fail to create H2 table and start Ignite cluster. 

For example, if I have a system which registers purchase orders and I called my custom class *Order* (which is reserved SQL keyword), I'll have such an error while trying to start Ignite cluster with *aaa* cache configured to store my *Order* objects:

*Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "CREATE TABLE ""aaa"".ORDER[*] (_KEY BIGINT NOT NULL,_VAL OTHER,ID BIGINT,PRODUCTID BIGINT,DATE TIMESTAMP,AMOUNT INT,PRICE REAL) ENGINE ""org.apache.ignite.internal.processors.query.h2.opt.GridH2Table$Engine"" "; expected "identifier"; SQL statement:
CREATE TABLE "aaa".Order (_key BIGINT NOT NULL,_val OTHER,id BIGINT,productId BIGINT,date TIMESTAMP,amount INT,price REAL) engine "org.apache.ignite.internal.processors.query.h2.opt.GridH2Table$Engine" [42001-191]*

At the same time, renaming *Order* class to something which is not SQL reserved keyword solves the problem, but from the object model design perspective looks not very good - cause *Order* class name reflects the main idea of the class.

To prevent the problem, it's necessary to wrap table and column names with escape characters (double quotes) in generated SQL statements.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)