asanchez75 / log4jdbc

Automatically exported from code.google.com/p/log4jdbc
0 stars 0 forks source link

support sql format ( sql beautify) #26

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
example:

source sql:
select * from userinfo u inner join role r on u.id = r.id inner join blog b on 
u.id = b.id where a=123 and diy=234

formated sql:
select
        * 
    from
        userinfo u 
    inner join
        role r     
            on u.id = r.id 
    inner join
        blog b 
            on u.id = b.id 
    where
        a=123 
        and diy=234

  /**
   * Slf4jSpyLogDelegator.processSql()
   */
  private String processSql(String sql)
  {
    // ... other codes
    if(formatSql) {
        return new BasicSqlFormatter().format(output.toString());
    }else {
        return output.toString();
    }
  }

attach file:BasicSqlFormatter.java is copy from hibernate

Original issue reported on code.google.com by bad...@gmail.com on 20 Aug 2010 at 3:21

Attachments:

GoogleCodeExporter commented 8 years ago
thanks for all your suggestions and patches.  I have been very busy lately.  I 
will take a look at them when I get a chance.

Original comment by arthur.b...@gmail.com on 25 Aug 2010 at 12:44

GoogleCodeExporter commented 8 years ago
One issue might be the licensing.  If I read things correctly, that code is 
LGPL.

Original comment by bruce.mi...@gmail.com on 26 Aug 2010 at 3:48

GoogleCodeExporter commented 8 years ago
good point.  I think it would be better to expose an API with various extension 
points so that people can easily write plugins for log4jdbc.  Something I've 
been thinking about doing anyway, for awhile.

Original comment by arthur.b...@gmail.com on 26 Aug 2010 at 2:02

GoogleCodeExporter commented 8 years ago
Some day, I will expose an API so you can write log4jdbc extensions and publish 
them on your own.  I don't want to contaminate the licensing with this change, 
but I may add my own SQL parsing/formatting at a future date.  Thanks! 

Original comment by arthur.b...@gmail.com on 8 Sep 2010 at 2:12

GoogleCodeExporter commented 8 years ago
Any update on this issue?

Original comment by robin....@gmail.com on 2 Oct 2012 at 8:38