mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
new feature : sql builder
This commit is contained in:
@@ -31,8 +31,7 @@ public class SQLOrderBy extends SQLObjectImpl {
|
||||
|
||||
public SQLOrderBy(SQLExpr expr){
|
||||
SQLSelectOrderByItem item = new SQLSelectOrderByItem(expr);
|
||||
item.setParent(this);
|
||||
this.items.add(item);
|
||||
addItem(item);
|
||||
}
|
||||
|
||||
public void addItem(SQLSelectOrderByItem item) {
|
||||
@@ -71,5 +70,14 @@ public class SQLOrderBy extends SQLObjectImpl {
|
||||
return items.equals(other.items);
|
||||
}
|
||||
|
||||
public void addItem(SQLExpr expr, SQLOrderingSpecification type) {
|
||||
SQLSelectOrderByItem item = createItem();
|
||||
item.setExpr(expr);
|
||||
item.setType(type);
|
||||
addItem(item);
|
||||
}
|
||||
|
||||
protected SQLSelectOrderByItem createItem() {
|
||||
return new SQLSelectOrderByItem();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,12 @@ public class SQLExprTableSource extends SQLTableSourceImpl {
|
||||
}
|
||||
|
||||
public SQLExprTableSource(SQLExpr expr){
|
||||
this(expr, null);
|
||||
}
|
||||
|
||||
public SQLExprTableSource(SQLExpr expr, String alias){
|
||||
this.setExpr(expr);
|
||||
this.setAlias(alias);
|
||||
}
|
||||
|
||||
public SQLExpr getExpr() {
|
||||
|
||||
@@ -82,6 +82,11 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
|
||||
public List<SQLSelectItem> getSelectList() {
|
||||
return this.selectList;
|
||||
}
|
||||
|
||||
public void addSelectItem(SQLSelectItem item) {
|
||||
this.selectList.add(item);
|
||||
item.setParent(this);
|
||||
}
|
||||
|
||||
public SQLTableSource getFrom() {
|
||||
return this.from;
|
||||
|
||||
@@ -75,6 +75,11 @@ public class SQLUpdateStatement extends SQLStatementImpl {
|
||||
public List<SQLUpdateSetItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void addItem(SQLUpdateSetItem item) {
|
||||
this.items.add(item);
|
||||
item.setParent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void output(StringBuffer buf) {
|
||||
|
||||
Reference in New Issue
Block a user