Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
bf51efce
提交
bf51efce
authored
5月 08, 2015
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
BNF auto-completion failed with unquoted identifiers.
上级
26d0db53
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
60 行增加
和
6 行删除
+60
-6
changelog.html
h2/src/docsrc/html/changelog.html
+4
-1
Bnf.java
h2/src/main/org/h2/bnf/Bnf.java
+11
-0
RuleFixed.java
h2/src/main/org/h2/bnf/RuleFixed.java
+15
-2
RuleRepeat.java
h2/src/main/org/h2/bnf/RuleRepeat.java
+5
-0
help.csv
h2/src/main/org/h2/res/help.csv
+1
-0
BnfRandom.java
h2/src/test/org/h2/test/synth/BnfRandom.java
+1
-0
TestBnf.java
h2/src/test/org/h2/test/unit/TestBnf.java
+23
-3
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
bf51efce
...
...
@@ -20,7 +20,10 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Oracle compatibility: empty strings were not converted to NULL when using prepared statements.
<ul>
<li>
BNF auto-completion failed with unquoted identifiers.
</li>
<li>
Oracle compatibility: empty strings were not converted to NULL when using prepared statements.
</li><li>
PostgreSQL compatibility: new syntax "create index ... using ...".
</li><li>
There was a bug in DataType.convertToValue when reading a ResultSet from a ResultSet.
</li><li>
Pull request #116: Improved concurrency in the trace system.
...
...
h2/src/main/org/h2/bnf/Bnf.java
浏览文件 @
bf51efce
...
...
@@ -57,6 +57,17 @@ public class Bnf {
return
bnf
;
}
/**
* Add an alias for a rule.
*
* @param name for example "procedure"
* @param replacement for example "@func@"
*/
public
void
addAlias
(
String
name
,
String
replacement
)
{
RuleHead
head
=
ruleMap
.
get
(
replacement
);
ruleMap
.
put
(
name
,
head
);
}
private
void
addFixedRule
(
String
name
,
int
fixedType
)
{
Rule
rule
=
new
RuleFixed
(
fixedType
);
addRule
(
name
,
"Fixed"
,
rule
);
...
...
h2/src/main/org/h2/bnf/RuleFixed.java
浏览文件 @
bf51efce
...
...
@@ -44,6 +44,7 @@ public class RuleFixed implements Rule {
sentence
.
stopIfRequired
();
String
query
=
sentence
.
getQuery
();
String
s
=
query
;
boolean
removeTrailingSpaces
=
false
;
switch
(
type
)
{
case
YMD:
while
(
s
.
length
()
>
0
&&
"0123456789-"
.
indexOf
(
s
.
charAt
(
0
))
>=
0
)
{
...
...
@@ -52,6 +53,8 @@ public class RuleFixed implements Rule {
if
(
s
.
length
()
==
0
)
{
sentence
.
add
(
"2006-01-01"
,
"1"
,
Sentence
.
KEYWORD
);
}
// needed for timestamps
removeTrailingSpaces
=
true
;
break
;
case
HMS:
while
(
s
.
length
()
>
0
&&
"0123456789:"
.
indexOf
(
s
.
charAt
(
0
))
>=
0
)
{
...
...
@@ -68,6 +71,7 @@ public class RuleFixed implements Rule {
if
(
s
.
length
()
==
0
)
{
sentence
.
add
(
"nanoseconds"
,
"0"
,
Sentence
.
KEYWORD
);
}
removeTrailingSpaces
=
true
;
break
;
case
ANY_EXCEPT_SINGLE_QUOTE:
while
(
true
)
{
...
...
@@ -135,6 +139,7 @@ public class RuleFixed implements Rule {
}
else
if
(
s
.
length
()
==
0
)
{
sentence
.
add
(
"||"
,
"||"
,
Sentence
.
KEYWORD
);
}
removeTrailingSpaces
=
true
;
break
;
case
AZ_UNDERSCORE:
if
(
s
.
length
()
>
0
&&
...
...
@@ -170,6 +175,7 @@ public class RuleFixed implements Rule {
}
else
if
(
s
.
charAt
(
0
)
==
'['
)
{
s
=
s
.
substring
(
1
);
}
removeTrailingSpaces
=
true
;
break
;
case
CLOSE_BRACKET:
if
(
s
.
length
()
==
0
)
{
...
...
@@ -177,6 +183,7 @@ public class RuleFixed implements Rule {
}
else
if
(
s
.
charAt
(
0
)
==
']'
)
{
s
=
s
.
substring
(
1
);
}
removeTrailingSpaces
=
true
;
break
;
// no autocomplete support for comments
// (comments are not reachable in the bnf tree)
...
...
@@ -186,8 +193,14 @@ public class RuleFixed implements Rule {
throw
new
AssertionError
(
"type="
+
type
);
}
if
(!
s
.
equals
(
query
))
{
while
(
Bnf
.
startWithSpace
(
s
))
{
s
=
s
.
substring
(
1
);
// can not always remove spaces here, because a repeat
// rule for a-z would remove multiple words
// but we have to remove spaces after '||'
// and after ']'
if
(
removeTrailingSpaces
)
{
while
(
Bnf
.
startWithSpace
(
s
))
{
s
=
s
.
substring
(
1
);
}
}
sentence
.
setQuery
(
s
);
return
true
;
...
...
h2/src/main/org/h2/bnf/RuleRepeat.java
浏览文件 @
bf51efce
...
...
@@ -36,6 +36,11 @@ public class RuleRepeat implements Rule {
while
(
rule
.
autoComplete
(
sentence
))
{
// nothing to do
}
String
s
=
sentence
.
getQuery
();
while
(
Bnf
.
startWithSpace
(
s
))
{
s
=
s
.
substring
(
1
);
}
sentence
.
setQuery
(
s
);
return
true
;
}
...
...
h2/src/main/org/h2/res/help.csv
浏览文件 @
bf51efce
...
...
@@ -711,6 +711,7 @@ value
| ?[ int ]
| NEXT VALUE FOR sequenceName
| function
| procedure
| { - | + } term
| ( expression )
| select
...
...
h2/src/test/org/h2/test/synth/BnfRandom.java
浏览文件 @
bf51efce
...
...
@@ -29,6 +29,7 @@ public class BnfRandom implements BnfVisitor {
public
BnfRandom
()
throws
Exception
{
Bnf
config
=
Bnf
.
getInstance
(
null
);
config
.
addAlias
(
"procedure"
,
"@func@"
);
config
.
linkStatements
();
ArrayList
<
RuleHead
>
all
=
config
.
getStatements
();
...
...
h2/src/test/org/h2/test/unit/TestBnf.java
浏览文件 @
bf51efce
...
...
@@ -140,11 +140,31 @@ public class TestBnf extends TestBase {
DbContextRule
(
dbContents
,
DbContextRule
.
PROCEDURE
));
bnf
.
linkStatements
();
// Test partial
Map
<
String
,
String
>
tokens
=
bnf
.
getNextTokenList
(
"SELECT CUSTOM_PR"
);
Map
<
String
,
String
>
tokens
;
tokens
=
bnf
.
getNextTokenList
(
"SELECT CUSTOM_PR"
);
assertTrue
(
tokens
.
values
().
contains
(
"INT"
));
// Test built-in function
tokens
=
bnf
.
getNextTokenList
(
"SELECT LEAS"
);
// Test identifiers are working
tokens
=
bnf
.
getNextTokenList
(
"create table \"test\" as sel"
);
assertTrue
(
tokens
.
values
().
contains
(
"ECT"
));
tokens
=
bnf
.
getNextTokenList
(
"create table test as sel"
);
assertTrue
(
tokens
.
values
().
contains
(
"ECT"
));
// Test || with and without spaces
tokens
=
bnf
.
getNextTokenList
(
"select 1||f"
);
assertFalse
(
tokens
.
values
().
contains
(
"ROM"
));
tokens
=
bnf
.
getNextTokenList
(
"select 1 || f"
);
assertFalse
(
tokens
.
values
().
contains
(
"ROM"
));
tokens
=
bnf
.
getNextTokenList
(
"select 1 || 2 "
);
assertTrue
(
tokens
.
values
().
contains
(
"FROM"
));
tokens
=
bnf
.
getNextTokenList
(
"select 1||2"
);
assertTrue
(
tokens
.
values
().
contains
(
"FROM"
));
tokens
=
bnf
.
getNextTokenList
(
"select 1 || 2"
);
assertTrue
(
tokens
.
values
().
contains
(
"FROM"
));
// Test keyword
tokens
=
bnf
.
getNextTokenList
(
"SELECT LE"
+
"AS"
);
assertTrue
(
tokens
.
values
().
contains
(
"T"
));
// Test parameters
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论