-
Notifications
You must be signed in to change notification settings - Fork 8.6k
feat: enhance support for oracle using_index_clause #6461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package com.alibaba.druid.sql.dialect.oracle.parser; | ||
|
|
||
| import com.alibaba.druid.DbType; | ||
| import com.alibaba.druid.sql.SQLUtils; | ||
| import com.alibaba.druid.sql.ast.SQLStatement; | ||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| public class OracleUsingIndexTest { | ||
|
|
||
|
|
||
| @Test | ||
| public void testUsingIndex() { | ||
|
||
| String sql = "ALTER TABLE \"SC\".\"TB1\"\n" + | ||
| "\tADD CONSTRAINT \"PK_XXX\" PRIMARY KEY (\"ID\")\n" + | ||
| "\t\tUSING INDEX \"SC\".\"PK_XXX\"\n" + | ||
| "\t\tENABLE"; | ||
| SQLStatement stat = SQLUtils.parseSingleStatement(sql, DbType.oracle,false); | ||
| System.out.println(stat); | ||
| Assert.assertEquals(sql, stat.toString()); | ||
| System.out.println("============="); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if分支不够健壮,可能还有IDENTIFIER 或其他 token,建议补充其他情况使用else if
直接用 OracleStatementParser(lexer).getExprParser().name() 解析 index 名称,可能会影响 lexer 状态,建议复用当前 parser 实例,避免新建对象导致上下文丢失。
没有进行异常处理,建议补充异常处理和日志