WriteExpireCondition writes a condition with the time column
(expire time.Time)
| 169 | |
| 170 | // WriteExpireCondition writes a condition with the time column |
| 171 | func (b *SQLBuilder) WriteExpireCondition(expire time.Time) error { |
| 172 | switch b.state { |
| 173 | case writeSelOrDel: |
| 174 | b.restoreCtx.WritePlain(" WHERE ") |
| 175 | b.state = writeWhere |
| 176 | case writeWhere: |
| 177 | b.restoreCtx.WritePlain(" AND ") |
| 178 | default: |
| 179 | return errors.Errorf("invalid state: %v", b.state) |
| 180 | } |
| 181 | |
| 182 | b.writeColNames([]*model.ColumnInfo{b.tbl.TimeColumn}, false) |
| 183 | b.restoreCtx.WritePlain(" < ") |
| 184 | b.restoreCtx.WritePlain("FROM_UNIXTIME(") |
| 185 | b.restoreCtx.WritePlain(strconv.FormatInt(expire.Unix(), 10)) |
| 186 | b.restoreCtx.WritePlain(")") |
| 187 | b.hasWriteExpireCond = true |
| 188 | return nil |
| 189 | } |
| 190 | |
| 191 | // WriteInCondition writes an IN condition |
| 192 | func (b *SQLBuilder) WriteInCondition(cols []*model.ColumnInfo, dps ...[]types.Datum) error { |