parseSequenceOptions parses sequence option keywords until no more are found.
()
| 147 | |
| 148 | // parseSequenceOptions parses sequence option keywords until no more are found. |
| 149 | func (p *Parser) parseSequenceOptions() (ast.SequenceOptions, error) { |
| 150 | var opts ast.SequenceOptions |
| 151 | for { |
| 152 | if p.isType(models.TokenTypeSemicolon) || p.isType(models.TokenTypeEOF) { |
| 153 | break |
| 154 | } |
| 155 | |
| 156 | word := strings.ToUpper(p.currentToken.Token.Value) |
| 157 | switch word { |
| 158 | case "START": |
| 159 | p.advance() |
| 160 | if strings.EqualFold(p.currentToken.Token.Value, "WITH") { |
| 161 | p.advance() |
| 162 | } |
| 163 | lit, err := p.parseNumericLit() |
| 164 | if err != nil { |
| 165 | return opts, err |
| 166 | } |
| 167 | opts.StartWith = lit |
| 168 | case "INCREMENT": |
| 169 | p.advance() |
| 170 | if strings.EqualFold(p.currentToken.Token.Value, "BY") { |
| 171 | p.advance() |
| 172 | } |
| 173 | lit, err := p.parseNumericLit() |
| 174 | if err != nil { |
| 175 | return opts, err |
| 176 | } |
| 177 | opts.IncrementBy = lit |
| 178 | case "MINVALUE": |
| 179 | p.advance() |
| 180 | lit, err := p.parseNumericLit() |
| 181 | if err != nil { |
| 182 | return opts, err |
| 183 | } |
| 184 | opts.MinValue = lit |
| 185 | case "MAXVALUE": |
| 186 | p.advance() |
| 187 | lit, err := p.parseNumericLit() |
| 188 | if err != nil { |
| 189 | return opts, err |
| 190 | } |
| 191 | opts.MaxValue = lit |
| 192 | case "NO": |
| 193 | p.advance() |
| 194 | sub := strings.ToUpper(p.currentToken.Token.Value) |
| 195 | p.advance() |
| 196 | switch sub { |
| 197 | case "MINVALUE": |
| 198 | opts.MinValue = nil |
| 199 | case "MAXVALUE": |
| 200 | opts.MaxValue = nil |
| 201 | case "CYCLE": |
| 202 | opts.CycleMode = ast.NoCycleBehavior |
| 203 | case "CACHE": |
| 204 | opts.Cache = nil |
| 205 | opts.NoCache = true |
| 206 | default: |
no test coverage detected