Skip to content

Commit

Permalink
更新解析器bug,未修改代码
Browse files Browse the repository at this point in the history
  • Loading branch information
akwei committed Sep 29, 2012
1 parent 403db5e commit 44aaea4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
29 changes: 23 additions & 6 deletions src/main/java/halo/dal/analysis/antlr/v3/AntlrV3SQL.g
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,29 @@ sql_update

sql_select
:
SELECT select_columns FROM tables
((FULL|CROSS|INNER|LEFT|RIGHT) JOIN table (ON column_name '=' column_name)?)*
(WHERE kv ( and_or (kv | column_name op '\(' sql_select '\)') )*)?
(orderby|groupby|having)*
SELECT select_columns FROM (sqlAfterFrom|inner_select) (WHERE kv_sql)? (orderby|groupby|having)*
;

sqlAfterFrom
:
tables ((FULL|CROSS|INNER|LEFT|RIGHT) JOIN table (ON column_name '=' column_name)?)*;

kv_sql_wrapper
:
kv_sql | '\(' kv_sql '\)'
;
kv_sql :
kv ( and_or (kv | '\(' kv (and_or kv)* '\)') )*
;

inner_select
:
'\(' sql_select '\)'
;

func
:
BASIC_NAME '\(' (BASIC_NAME|'*') '\)'
BASIC_NAME '\(' (BASIC_NAME|'*')? '\)'
;

func_and_alias
Expand Down Expand Up @@ -117,9 +131,10 @@ insertColumn
**/
}
;


kv :
(column_name op PRE_SET)
(column_name op (PRE_SET|'\(' PRE_SET '\)'))
{
colExprs.add(new String[]{$column_name.text,$op.text});
/**
Expand All @@ -136,6 +151,8 @@ kv :
column_name op column_name
|
column_name op func2
|
column_name op '\(' sql_select '\)'
;

func2 :
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/halo/dal/analysis/antlr/v3/sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GATEWAYEVE0_.START_DATE AS START15_1_
FROM gateway_event1 GATEWAYEVE0_ , table2 as t2
WHERE 1=? and 1=2 or 3.5=6.7 and b='s do' and time=sysdate()
or name=substring(a.b,'c',b,b.c,'') and kk=substring('')
and name between ? and ?
and name >= ? and name > ?
and uid in (select * from user where sex=? order by gid desc group by ss having a=b.c)
AND GATEWAYEVE0_.EVENT_STATUS=?

Expand All @@ -18,7 +18,7 @@ FROM
SELECT n.ID AS nodeId, n.name AS nodeName , f.name AS taskflowName,
f.version AS taskflowVersion
FROM HT_TASK_FLOW_NODE_WA_2 n, HT_TASK_FLOW_WA_2 f
WHERE n.owner = ? AND name between ? and ? and
WHERE n.owner = ? AND name >= ? and name <= ? and
(
n.STATUS IN (?) AND n.GMT_MODIFIED < ? AND n.IS_AUTO = 'Y' AND n.task_flow_id = f.id
)
Expand All @@ -40,4 +40,8 @@ sysdate()

substring(a.b,'c',b,b.c,'')

substring('')
substring('')

select * from(
select id, name, rownumber() over(order by id asc) as rowid from db2.table_name
) temp where temp.rowid >= startNumber and temp.rowid <= endNumber

0 comments on commit 44aaea4

Please sign in to comment.