-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed as not planned
Closed as not planned
Copy link
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: enhancementA general enhancementA general enhancement
Description
Michel Zanini opened SPR-9236 and commented
If you have table or column names that are reserved SQL words, like "varchar", "values", "integer", etc... the generated insert SQL must have escaping.
For example, now SimpleJdbcInsert is generating this SQL:
INSERT INTO crud (text, integer, char, datetime, decimal, varchar) VALUES(?, ?, ?, ?, ?, ?)but it should be generating this:
INSERT INTO `crud` (`text`, `integer`, `char`, `datetime`, `decimal`, `varchar`) VALUES(?, ?, ?, ?, ?, ?)As a workaround I am able to make it work adding the escape char "`" to the column names like this:
simpleJdbcInsert.withTableName("`" + tableName + "`");
simpleJdbcInsert.usingColumns("`" + column1 + "`", "`" + column2 + "`", "`" + column3 + "`");but I believe SimpleJdbcInsert should support this out of the box. For example, it could have a boolean property like this:
simpleJdbcInsert.withTableName(tableName);
simpleJdbcInsert.usingColumns(column1, column2, column3);
simpleJdbcInsert.usingEscaping(true);and then SimpleJdbcInsert would do the escaping for me.
Affects: 3.1.1
4 votes, 6 watchers
Metadata
Metadata
Assignees
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: enhancementA general enhancementA general enhancement