Build builds the final sql
()
| 93 | |
| 94 | // Build builds the final sql |
| 95 | func (b *SQLBuilder) Build() (string, error) { |
| 96 | if b.state == writeBegin { |
| 97 | return "", errors.Errorf("invalid state: %v", b.state) |
| 98 | } |
| 99 | |
| 100 | if !b.isReadOnly && !b.hasWriteExpireCond { |
| 101 | // check whether the `timeRow < expire_time` condition has been written to make sure this SQL is safe. |
| 102 | return "", errors.New("expire condition not write") |
| 103 | } |
| 104 | |
| 105 | if b.state != writeDone { |
| 106 | b.state = writeDone |
| 107 | } |
| 108 | |
| 109 | return b.sb.String(), nil |
| 110 | } |
| 111 | |
| 112 | // WriteSelect writes a select statement to select key columns without any condition |
| 113 | func (b *SQLBuilder) WriteSelect() error { |