提交 073332f2 编写于 作者: T terrymanu

remove sql server unnecessary codes

上级 82451164
/*
* Copyright 1999-2101 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.dialect.sqlserver.ast;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SQLServerTop extends SQLObjectImpl {
private SQLExpr expr;
private boolean percent;
public void setExpr(final SQLExpr expr) {
if (null != expr) {
expr.setParent(this);
}
this.expr = expr;
}
}
/*
* Copyright 1999-2101 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.context;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SQLServerTop extends SQLObjectImpl {
private SQLExpr expr;
private boolean percent;
public void setExpr(final SQLExpr expr) {
if (null != expr) {
expr.setParent(this);
}
this.expr = expr;
}
}
/*
* Copyright 1999-2101 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.dialect.sqlserver.ast;
import com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock;
import lombok.Getter;
@Getter
public class SQLServerSelectQueryBlock extends SQLSelectQueryBlock {
private SQLServerTop top;
public void setTop(final SQLServerTop top) {
if (null != top) {
top.setParent(this);
}
this.top = top;
}
}
......@@ -28,6 +28,7 @@ public enum SQLServerKeyword implements Keyword {
TOP,
OFFSET,
PERCENT,
ONLY,
IF,
OUTPUT,
......
......@@ -18,7 +18,7 @@ package com.alibaba.druid.sql.dialect.sqlserver.parser;
import com.alibaba.druid.sql.context.LimitContext;
import com.alibaba.druid.sql.context.SelectSQLContext;
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerTop;
import com.alibaba.druid.sql.context.SQLServerTop;
import com.alibaba.druid.sql.dialect.sqlserver.lexer.SQLServerKeyword;
import com.alibaba.druid.sql.dialect.sqlserver.lexer.SQLServerLexer;
import com.alibaba.druid.sql.lexer.DataType;
......@@ -40,7 +40,7 @@ public class SQLServerExprParser extends SQLExprParser {
public SQLServerTop parseTop() {
// TODO
// if (getLexer().equalToken(Token.TOP)) {
// if (getLexer().equalToken(SQLServerKeyword.TOP)) {
// SQLServerTop top = new SQLServerTop();
// getLexer().nextToken();
//
......@@ -56,7 +56,7 @@ public class SQLServerExprParser extends SQLExprParser {
// getLexer().accept(Symbol.RIGHT_PAREN);
// }
//
// if (getLexer().equalToken(Token.PERCENT)) {
// if (getLexer().equalToken(SQLServerKeyword.PERCENT)) {
// getLexer().nextToken();
// top.setPercent(true);
// }
......
......@@ -16,7 +16,6 @@
package com.alibaba.druid.sql.dialect.sqlserver.parser;
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelectQueryBlock;
import com.alibaba.druid.sql.dialect.sqlserver.lexer.SQLServerKeyword;
import com.alibaba.druid.sql.lexer.DataType;
import com.alibaba.druid.sql.lexer.DefaultKeyword;
......@@ -43,7 +42,6 @@ public class SQLServerSelectParser extends AbstractSelectParser {
@Override
public void query() {
SQLServerSelectQueryBlock queryBlock = new SQLServerSelectQueryBlock();
if (getExprParser().getLexer().equalToken(DefaultKeyword.SELECT)) {
getExprParser().getLexer().nextToken();
if (getExprParser().getLexer().equalToken(DataType.COMMENT)) {
......@@ -51,7 +49,8 @@ public class SQLServerSelectParser extends AbstractSelectParser {
}
parseDistinct();
if (getExprParser().getLexer().equalToken(SQLServerKeyword.TOP)) {
queryBlock.setTop(((SQLServerExprParser) getExprParser()).parseTop());
// TODO save topContext
((SQLServerExprParser) getExprParser()).parseTop();
}
parseSelectList();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册