我可以将JOOQ用作SQL解析器吗? [英] Can I use JOOQ as an SQL parser?

查看:207
本文介绍了我可以将JOOQ用作SQL解析器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解析Java中的SELECT语句.我熟悉JOOQ,并希望使用它.我知道它没有明确设计为SQL解析器,实际上它还不止于此,所以我在想可能有一种使用其内部解析器解析SELECT查询的方法.

I'm trying to parse a SELECT statement in Java. I'm familiar with JOOQ, and was hoping to use that. I know it's not explicitly designed as an SQL parser—it's actually a lot more than that, so I was thinking there might be a way to use its internal parsers to parse SELECT queries.

我看到了一些有关如何使用Visitor模式访问JOOQ内部构件的信息,但是我需要使用树状结构在查询内部进行导航,该结构将允许分别访问查询的每个部分.我不想在所有用例中都使用访客"模式.

I saw some information on how to access some of JOOQ's internals using the Visitor pattern, but I need to navigate inside the query using a tree-like structure that will allow access to each part of the query individually. I don't want to use the Visitor pattern for all use cases.

这可能吗?我将如何去做呢?

Is this possible? How would I go about doing it?

推荐答案

从jOOQ 3.11开始,尽管您确实可以使用VisitListener并进行一些内部调整(主要取决于通过反射的内部类型)来提取表达式树. ,您目前无法执行任何操作.将来,当可以通过公共API来访问表达式树(并且与SQL生成逻辑完全分离)时,将解决该问题,但现在还没有任何承诺.

As of jOOQ 3.11, while you can indeed extract the expression tree using a VisitListener and some tweaking of the internals (mainly depending on internal types via reflection), what you want to do is currently not possible. It will be addressed in the future, when the expression tree might be made accessible through public API (and cleanly separated from the SQL generation logic), but no promises yet.

这篇关于我可以将JOOQ用作SQL解析器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆