fix escape bug
This commit is contained in:
parent
ff77c1b0ac
commit
77bbf57d28
@ -97,3 +97,9 @@ console.log(dtSqlParser.parseSyntax("selet * form",'hive'));
|
|||||||
ast生成代码来自[nquery](https://github.com/alibaba/nquery/)
|
ast生成代码来自[nquery](https://github.com/alibaba/nquery/)
|
||||||
|
|
||||||
hive,impala等语法解析文件来自[Hue](https://github.com/cloudera/hue)
|
hive,impala等语法解析文件来自[Hue](https://github.com/cloudera/hue)
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
### ChangeLog
|
||||||
|
|
||||||
|
- 1.1.8 添加转义字符支持
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -521,7 +521,7 @@ ROW_NUMBER\s*\( { yy.lexer.unput('('); yytext = 'row_
|
|||||||
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
<backtickedValue>\` { this.popState(); return 'BACKTICK'; }
|
||||||
|
|
||||||
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
\' { this.begin('singleQuotedValue'); return 'SINGLE_QUOTE'; }
|
||||||
<singleQuotedValue>(?:\\[']|[^'])+ {
|
<singleQuotedValue>(?:\\\\|\\[']|[^'])+ {
|
||||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '\'')) {
|
||||||
return 'PARTIAL_VALUE';
|
return 'PARTIAL_VALUE';
|
||||||
}
|
}
|
||||||
@ -530,7 +530,7 @@ ROW_NUMBER\s*\( { yy.lexer.unput('('); yytext = 'row_
|
|||||||
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
<singleQuotedValue>\' { this.popState(); return 'SINGLE_QUOTE'; }
|
||||||
|
|
||||||
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
\" { this.begin('doubleQuotedValue'); return 'DOUBLE_QUOTE'; }
|
||||||
<doubleQuotedValue>(?:\\["]|[^"])+ {
|
<doubleQuotedValue>(?:\\\\|\\["]|[^"])+ {
|
||||||
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
if (parser.handleQuotedValueWithCursor(this, yytext, yylloc, '"')) {
|
||||||
return 'PARTIAL_VALUE';
|
return 'PARTIAL_VALUE';
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dt-sql-parser",
|
"name": "dt-sql-parser",
|
||||||
"version": "1.1.7",
|
"version": "1.1.8",
|
||||||
"description": "sql,hive,parser ",
|
"description": "sql,hive,parser ",
|
||||||
"keywords":["hive","hql","sql","parser"],
|
"keywords":["hive","hql","sql","parser"],
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
const example={
|
const example={
|
||||||
test0:`--alter table sx_622_1 add partition(pa=${"${bdp.system.bizdate}"});
|
test0:`create table t_csv(
|
||||||
SELECT muyun_test_down1.id, muyun_test_down1.name, muyun_test_down2.age
|
id int,
|
||||||
FROM muyun_test_down1
|
name string,
|
||||||
JOIN muyun_test_down2
|
address string,
|
||||||
ON muyun_test_down1.id = muyun_test_down2.id
|
sex tinyint
|
||||||
|
)row format serde'org.apache.hadoop.hive.serde2.OpenCSVSerde'with serdeproperties(
|
||||||
|
"separatorChar"=",",
|
||||||
|
"quoteChar"="'","escapeChar"="")stored as textfile;
|
||||||
`,
|
`,
|
||||||
test1:`/*asf*/create table sql_task_comment_test(id int comment 'id') comment 'sql test';
|
test1:`/*asf*/create table sql_task_comment_test(id int comment 'id') comment 'sql test';
|
||||||
--sdfsss`,
|
--sdfsss`,
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
const dtSqlParser=require("../index");
|
const dtSqlParser=require("../index");
|
||||||
const example=require("./example");
|
const example=require("./example");
|
||||||
const testMap=Object.entries(example);
|
const testMap=Object.entries(example);
|
||||||
|
const filterSql=dtSqlParser.filter.filterComments;
|
||||||
|
const splitSql=dtSqlParser.filter.splitSql;
|
||||||
|
|
||||||
for(let [key,value] of testMap){
|
for(let [key,value] of testMap){
|
||||||
console.log(`******${key}********`)
|
console.log(`******${key}********`)
|
||||||
console.log(value)
|
console.log(value)
|
||||||
console.log(`******result********`)
|
console.log(`******result********`)
|
||||||
console.log(dtSqlParser.parser.parseSyntax(value));
|
// console.log(dtSqlParser.parser.parseSyntax(value));
|
||||||
// console.log(dtSqlParser.filter.splitSql(value))
|
console.log(splitSql(filterSql(value)))
|
||||||
console.log(`********************`)
|
console.log(`********************`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user