@date 2019年4月30日上午09:58:02 @desc Insert语法操作类
| 25 | * @desc Insert语法操作类 |
| 26 | */ |
| 27 | public class Insert extends com.sql.parse.statement.Insert { |
| 28 | private net.sf.jsqlparser.statement.insert.Insert insert; |
| 29 | |
| 30 | public Insert(net.sf.jsqlparser.statement.insert.Insert insert) { |
| 31 | this.insert = insert; |
| 32 | } |
| 33 | |
| 34 | public Insert(String tableName) { |
| 35 | net.sf.jsqlparser.statement.insert.Insert insert = new net.sf.jsqlparser.statement.insert.Insert(); |
| 36 | insert.setTable(new Table(tableName)); |
| 37 | this.insert = insert; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public String getSql(boolean safe) { |
| 42 | if (this.insert.getSelect() == null && this.insert.getItemsList() == null) { |
| 43 | throw BaseException.errorCode(SqlParseConstant.CODE_014); |
| 44 | } else { |
| 45 | return this.insert.toString(); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | public net.sf.jsqlparser.statement.insert.Insert getInsert() { |
| 50 | return this.insert; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @title: addColumn |
| 55 | * @desc 新增insert数据列 |
| 56 | */ |
| 57 | public Insert addColumn(String column) { |
| 58 | if(insert.getColumns()==null){ |
| 59 | insert.setColumns(new ArrayList<Column>()); |
| 60 | } |
| 61 | insert.getColumns().add(new Column(column)); |
| 62 | return this; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @title: addColumn |
| 67 | * @desc 新增insert数据列 |
| 68 | */ |
| 69 | public Insert addColumn(String column, String value) { |
| 70 | return addColumn(new InsertItem(column, value)); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @title: addColumn |
| 75 | * @desc 新增insert数据列 |
| 76 | */ |
| 77 | public Insert addColumn(InsertItem insertItem) { |
| 78 | if (insert.getSelect() == null) { |
| 79 | if (insert.getItemsList() == null) { |
| 80 | insert.setItemsList(new ExpressionList(new ArrayList<Expression>())); |
| 81 | insert.setUseValues(true); |
| 82 | } |
| 83 | if (insert.getColumns() == null) { |
| 84 | insert.setColumns(new ArrayList<Column>()); |
nothing calls this directly
no outgoing calls
no test coverage detected