Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

querydsl-sql-codegen: wrong space/newline support on columns name #431

Closed
dmiorandi opened this issue Jun 4, 2013 · 2 comments
Closed

querydsl-sql-codegen: wrong space/newline support on columns name #431

dmiorandi opened this issue Jun 4, 2013 · 2 comments
Labels
Milestone

Comments

@dmiorandi
Copy link

@dmiorandi dmiorandi commented Jun 4, 2013

on reverse engeenering in class com.mysema.query.sql.codegen.MetaDataExporter the method handleColumn generate wrong bean propertyname and field name if the db column
contain a newline and or spaces. The generated java code does not compile because
new line in propertyname or in fieldname (string). I've patched myself to make it work.
I don't know if this is acceptable to commit, but work for me (I mean it produce a right java code, but it doesn't work when run the query because column name change).
An alternative should be to skip tables that contains new line in column name and print a warning.

   private void handleColumn(EntityType classModel, String tableName, ResultSet columns) throws SQLException {
        String columnName = normalize(columns.getString(COLUMN_NAME));
        columnName=columnName.replaceAll("\r", "");
        columnName=columnName.replaceAll("\n", "");
        int columnType = columns.getInt(COLUMN_TYPE);
        int columnSize = columns.getInt(COLUMN_SIZE);
        int columnDigits = columns.getInt(COLUMN_DIGITS);
        String propertyName = namingStrategy.getPropertyName(
                columnName.replaceAll("\\s+", " ")
                , classModel);```
timowest added a commit that referenced this issue Jun 8, 2013
@timowest
Copy link
Member

@timowest timowest commented Jun 26, 2013

Released in 3.2.1

@timowest timowest closed this Jun 26, 2013
@dmiorandi
Copy link
Author

@dmiorandi dmiorandi commented Sep 30, 2013

Hi Timo,
this patch seem not work. I suppose that some call to method normalizeColumnName are missing in handleColumn.
The fact is that in handleColumn method in MetaDataExporter my patched code works while 3.2.3 code are not working (generate columnName with newLine)

Patch was
private void handleColumn(EntityType classModel, String tableName, ResultSet columns) throws SQLException {
String columnName = normalize(columns.getString("COLUMN_NAME"));
columnName=columnName.replaceAll("\r", "");
columnName=columnName.replaceAll("\n", "");

timowest added a commit that referenced this issue Sep 30, 2013
@timowest timowest added this to the 3.2.1 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants