Add quoting for table and column names.

More reserved words have to be added to ddl2cpp
This commit is contained in:
rbock
2017-11-26 19:19:26 +01:00
parent 8ad1bb5db2
commit 109b0af880
13 changed files with 68 additions and 14 deletions
+11 -1
View File
@@ -249,6 +249,16 @@ if warnOnParse:
nsList = namespace.split('::')
def escape_if_reserved(name):
reserved_names = [
'GROUP',
'ORDER',
]
if name.upper() in reserved_names:
return '!{}'.format(name)
return name
# PROCESS DDL
tableCreations = ddl.parseFile(pathToDdl)
@@ -292,7 +302,7 @@ for create in tableCreations:
print(' {', file=header)
print(' struct _alias_t', file=header)
print(' {', file=header)
print(' static constexpr const char _literal[] = "' + sqlColumnName + '";', file=header)
print(' static constexpr const char _literal[] = "' + escape_if_reserved(sqlColumnName) + '";', file=header)
print(' using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;', file=header)
print(' template<typename T>', file=header)
print(' struct _member_t', file=header)