You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/09/27 09:07:20 UTC

[GitHub] [incubator-shardingsphere] linxux commented on issue #2673: Support query for `DB.TBL` in ShardingProxy

linxux commented on issue #2673: Support query for `DB.TBL` in ShardingProxy
URL: https://github.com/apache/incubator-shardingsphere/issues/2673#issuecomment-535858993
 
 
   > 麻烦问下 这个功能什么时候能上? 我用的是jooq
   
   Meet the same issue when using JOOQ query with `backticks`.
   e.g.,: 
   Raw SQL,
   ```sql
   select `user`.`id`, `user`.`name`, `user`.`timestamp`, `user`.`email` `user`.`version` from `user` where (`user`.`id` = 123 and `user`.`email` = 'your_email@test.com')
   ```
   Actual SQL after parser,
   ```sql
   select `user`.`id`, `user`.`name`, `user`.`timestamp`, `user`.`email` `user`.`version` from `user_21` where (user_21r`.`id` = 123 and user_21r`.`email` = 'your_email@test.com')
   ```
   
   ---
   Troubleshot:
   Unable parse the SQL correctly since the incorrect SQLTokens from FromWhereSegment, SelectItemSegment
   
   ---
   Workaround,
   1. Using table alias in query, verified
   ```java
   User author = Tables_USER.as("user");
   ```
   
   2. Using org.jooq.VisitListener SPI
   ```java
   public class UnqualifyingListener extends DefaultVisitListener {
       @Override
       public void visitStart(VisitContext context) {
           if (context.queryPart() instanceof TableField) {
               TableField<?, ?> field = (TableField<?, ?>) context.queryPart();
               context.queryPart(DSL.field(field.getUnqualifiedName(), field.getDataType()));
           }
       }
   }
   ```
   
   3. Using native SQL...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services