提交 dcbfd642 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Improve TestKeywords and add new context-sensitive keywords

上级 7a7e9252
......@@ -498,6 +498,8 @@ The following tokens are keywords in H2:
<td>CS</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>BETWEEN</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td>NR</td><td>+</td></tr>
<tr><td>BOTH</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>CASE</td>
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>CHECK</td>
......@@ -556,6 +558,8 @@ The following tokens are keywords in H2:
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>JOIN</td>
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>LEADING</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>LEFT</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>LIKE</td>
......@@ -612,6 +616,8 @@ The following tokens are keywords in H2:
<td>CS</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>TOP</td>
<td>CS</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>TRAILING</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>TRUE</td>
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>UNION</td>
......
......@@ -1553,7 +1553,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* The complete list of keywords (including SQL:2003 keywords) is:
* <pre>
* ALL, AND, ARRAY, AS,
* BETWEEN,
* BETWEEN, BOTH
* CASE, CHECK, CONSTRAINT, CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER,
* DISTINCT,
* EXCEPT, EXISTS,
......@@ -1562,7 +1562,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* HAVING,
* IF, ILIKE, IN, INNER, INTERSECT, INTERSECTS, INTERVAL, IS,
* JOIN,
* LEFT, LIKE, LIMIT, LOCALTIME, LOCALTIMESTAMP,
* LEADING, LEFT, LIKE, LIMIT, LOCALTIME, LOCALTIMESTAMP,
* MINUS,
* NATURAL, NOT, NULL,
* OFFSET, ON, OR, ORDER, OVER,
......@@ -1570,7 +1570,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* QUALIFY,
* REGEXP, RIGHT, ROW, _ROWID_, ROWNUM,
* SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP,
* TABLE, TODAY, TOP, TRUE,
* TABLE, TODAY, TOP, TRAILING, TRUE,
* UNION, UNIQUE,
* VALUES,
* WHERE, WINDOW, WITH
......
......@@ -412,7 +412,7 @@ public class ParserUtil {
return IDENTIFIER;
case 'B':
if (additionalKeywords) {
if (eq("BETWEEN", s, ignoreCase, start, end)) {
if (eq("BETWEEN", s, ignoreCase, start, end) || eq("BOTH", s, ignoreCase, start, end)) {
return KEYWORD;
}
}
......@@ -514,7 +514,7 @@ public class ParserUtil {
return LOCALTIMESTAMP;
}
if (additionalKeywords) {
if (eq("LEFT", s, ignoreCase, start, end)) {
if (eq("LEADING", s, ignoreCase, start, end) || eq("LEFT", s, ignoreCase, start, end)) {
return KEYWORD;
}
}
......@@ -587,7 +587,8 @@ public class ParserUtil {
return TRUE;
}
if (additionalKeywords) {
if (eq("TODAY", s, ignoreCase, start, end) || eq("TOP", s, ignoreCase, start, end)) {
if (eq("TODAY", s, ignoreCase, start, end) || eq("TOP", s, ignoreCase, start, end)
|| eq("TRAILING", s, ignoreCase, start, end)) {
return KEYWORD;
}
}
......
......@@ -93,6 +93,13 @@ public class TestKeywords extends TestBase {
assertFalse(rs.next());
assertEquals(s, rs.getMetaData().getColumnLabel(1));
}
stat.execute("DROP TABLE " + s);
stat.execute("CREATE TABLE TEST(" + s + " VARCHAR) AS VALUES '-'");
try (ResultSet rs = stat.executeQuery("SELECT TRIM(" + s + " FROM '--a--') FROM TEST")) {
assertTrue(rs.next());
assertEquals("a", rs.getString(1));
}
stat.execute("DROP TABLE TEST");
} catch (Throwable t) {
throw new AssertionError(s + " cannot be used as identifier.", t);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论