Open CembZy opened 4 years ago
当cross join关联多个表的时候,不能成功转换。 test case: Select from table_c as v cross join table_b, table_c 转换后: Select from table_c as v cross join table_b, table_c
查看源码发现:
private boolean hasJoin( TJoinList joins ) { if ( joins == null ) return false; for ( int i = 0; i < joins.size( ); i++ ) { if ( joins.getJoin( i ).getJoinItems( ) != null && joins.getJoin( i ).getJoinItems( ).size( ) > 0 ) return true; } return false; }
当cross join关联表的时候, joins.getJoin( i ).getJoinItems( )不为null,并且size大于0直接返回了true,导致没有进入cross join的转换方法中,但是cross join的getJoinItems( )实际上应该为null,因为joins.getJoin(i).getJoinItems().getJoinItem(j).toString()为null,cross join的hasJoin校验应该为false,缺少这一步判断,所以会导致直接不能转换,修改源码为:
private boolean hasJoin(TJoinList joins) { if (joins == null) return false; for (int i = 0; i < joins.size(); i++) { TJoinItemList joinItems = joins.getJoin(i).getJoinItems(); if (null != joinItems && joinItems.size() > 0) { for (int j = 0; j < joinItems.size(); j++) { if (null == joinItems.getJoinItem(j).toString()) { return false; } } return true; } } return false; }
即可。
当cross join关联多个表的时候,不能成功转换。 test case: Select from table_c as v cross join table_b, table_c 转换后: Select from table_c as v cross join table_b, table_c
查看源码发现:
当cross join关联表的时候, joins.getJoin( i ).getJoinItems( )不为null,并且size大于0直接返回了true,导致没有进入cross join的转换方法中,但是cross join的getJoinItems( )实际上应该为null,因为joins.getJoin(i).getJoinItems().getJoinItem(j).toString()为null,cross join的hasJoin校验应该为false,缺少这一步判断,所以会导致直接不能转换,修改源码为:
即可。