grebeniuk / Java2SQL

Eclipse plug-in that transforms Java strings with constant to SQL text and replaces constants with their values.
1 stars 0 forks source link

Wrong sql formatting for queries without \n ending on each line #1

Open Storchaka opened 13 years ago

Storchaka commented 13 years ago

For SQL queries in string SomeConsts without \n ending character on each line your plugging creates a result query in one line, so line formatting is lost.

Example

For

String query = " select warp2fanport.reference " + " from " + " table1 vlink, table2 vlink2rfs, " + " table1 warp, table2 warp2fanport " + " where " + " vlink.parent_id=? and vlink.type_id=" + SomeConsts.CONST1 + " and vlink2rfs.id=vlink.id and vlink2rfs.attribute_id=" + SomeConsts.CONST2 + " and warp.id=vlink2rfs.reference and warp.type_id=" + SomeConsts.CONST3 + " and warp2fanport.id=warp.id and warp2fanport.attribute_id=" + SomeConsts.CONST4;

result will be in one line

select warp2fanport.reference from table1 vlink, table2 vlink2rfs, table1 warp, table2 warp2fanport where vlink.parent_id=? and vlink.type_id=123 /SomeConsts.CONST1/ and vlink2rfs.id=vlink.id and vlink2rfs.attribute_id=234 /SomeConsts.CONST2/ and warp.id=vlink2rfs.reference and warp.type_id=345 /SomeConsts.CONST3/ and warp2fanport.id=warp.id and warp2fanport.attribute_id=768 /SomeConsts.CONST4/

grebeniuk commented 12 years ago

Hi!

Thanks for your issue, it is not so simple to implement such feature because plugin doesn't operates with strings it parses AST Nodes and there is no simple and fast way to do this without adding some "spikes". It doesn't mean that I'm not going to add described feature, just need some time to choose the best solution.

Will keep you updated, Andrey