btc-ag / redg

The RedG test data generation library
https://btc-ag.github.io/redg/
Apache License 2.0
10 stars 0 forks source link

[redg-generator, redg-runtime, redg-models] Issue with double-quote in column names #8

Closed olewehrmeyer closed 7 years ago

olewehrmeyer commented 7 years ago

When columns have certain names that are reserved keywords for some RDBMS, SchemaCrawler (or the RDBMS itself) wraps them in double quotes (a column named time gets returned as "time").

When RedG generates the code for a schema, these double quotes get extra escaped so they are valid in Java string literals ("time" becomes \"time\" in the model and thus in the Java source code). When the source code gets compiled the string gets un-escaped and the column name is "time" in memory, just like it is needed. But the column model (that gets serialized with the class) still saves \"time\" and comparisons will fail (like needed for default values when calling TableModel#getColumnBySQLName(String name)). Thus no default values can currently be generated for tables using reserved keywords as column names.

This currently has not affected table names, but the problem is the same.

Possible solutions:

olewehrmeyer commented 7 years ago

A similar problem is discussed in antlr/stringtemplate4#44 and a custom map that transforms strings is suggested as an easy yet good solution.