WriteCommonCondition writes a new condition
(cols []*model.ColumnInfo, op string, dp []types.Datum)
| 150 | |
| 151 | // WriteCommonCondition writes a new condition |
| 152 | func (b *SQLBuilder) WriteCommonCondition(cols []*model.ColumnInfo, op string, dp []types.Datum) error { |
| 153 | switch b.state { |
| 154 | case writeSelOrDel: |
| 155 | b.restoreCtx.WritePlain(" WHERE ") |
| 156 | b.state = writeWhere |
| 157 | case writeWhere: |
| 158 | b.restoreCtx.WritePlain(" AND ") |
| 159 | default: |
| 160 | return errors.Errorf("invalid state: %v", b.state) |
| 161 | } |
| 162 | |
| 163 | b.writeColNames(cols, len(cols) > 1) |
| 164 | b.restoreCtx.WritePlain(" ") |
| 165 | b.restoreCtx.WritePlain(op) |
| 166 | b.restoreCtx.WritePlain(" ") |
| 167 | return b.writeDataPoint(cols, dp) |
| 168 | } |
| 169 | |
| 170 | // WriteExpireCondition writes a condition with the time column |
| 171 | func (b *SQLBuilder) WriteExpireCondition(expire time.Time) error { |