eclipse / dirigible

Eclipse Dirigible™ Project
https://www.dirigible.io
Eclipse Public License 2.0
267 stars 90 forks source link

Escaping table name for MySQL not working #850

Closed Wildflowerr closed 3 years ago

Wildflowerr commented 3 years ago

If you want to create a table with the following XS Classic definition:

table.schemaName = "DBADMIN";
table.temporary = true;
table.tableType = COLUMNSTORE;
table.loggingType = NOLOGGING;
table.columns = [
 {name = "ID"; sqlType = INTEGER; unique= false; length = 40; nullable = false; comment = "hello"; defaultValue = 20; precision = 2; scale = 15;},
 {name = "NAME"; sqlType = VARCHAR; length = 20; nullable = false; },
 {name = "JOB"; sqlType = VARCHAR; length = 20; nullable = false;},
 {name = "NUMBER"; sqlType = INTEGER; length = 20; nullable = false; defaultValue = 444;}];
table.indexes =  [
 {name = "MYINDEX"; unique = false; indexColumns = ["ID"];},
 {name = "MYINDEX10"; unique = true; indexColumns = ["JOB", "NAME"];}];
table.primaryKey.pkcolumns = ["ID"];
table.description = "test table test";

SqlFactory creates query of the following form:

CREATE TABLE "hdbtable-itest::SamplePostgreXSClassicTable" ( ID INTEGER  DEFAULT 20  NOT NULL , NAME VARCHAR (20) NOT NULL , JOB VARCHAR (20) NOT NULL , NUMBER INTEGER  DEFAULT 444  NOT NULL , 
PRIMARY KEY ( ID ), CONSTRAINT "MYINDEX" UNIQUE ( ID ), 
CONSTRAINT "MYINDEX10" UNIQUE ( JOB , NAME ))

Such SQL syntax leads to a db error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"hdbtable-itest::SamplePostgreXSClassicTable"

According to mysql documentation, table names should be escaped with ` instead of " symbol.

Wildflowerr commented 3 years ago

Resolved with https://github.com/SAP/xsk/pull/191/commits/7df2f635b741effa0c776851be943a058488adf2