You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Vladimir Ozerov (JIRA)" <ji...@apache.org> on 2017/11/10 08:07:00 UTC

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

     [ https://issues.apache.org/jira/browse/IGNITE-3792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vladimir Ozerov resolved IGNITE-3792.
-------------------------------------
    Resolution: Won't Fix

Please use {{CacheConfiguration.sqlEscapeAll}} flag. It was introduced exactly for this purpose.

> 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: 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 (which was done for cache name, but for some reason wasn't done for table name).



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)