Commit 8106d25
committed
Don't fail parsing a column definition with unexpected tokens
Since PR #93
`parse_column_def` parses a set of column options in a loop, e.g. given:
```
_______ column_def _______
CREATE TABLE foo (bar INT NOT NULL DEFAULT 1, )
-------- ---------
option 1 option 2
````
it parses column options until it encounters one of the delimiter tokens
First when we only supported `CREATE TABLE`, the set of delimiters that
stopped the parsing used to be `Token::Comma | Token::RParen`.
Then we added support for `ALTER TABLE ADD COLUMN <column_def>`. Turns
out the parser started to bail if the statement ended with a semicolon,
while attempting to parse the semicolon as a column option, as we forgot
to add it to the set of delimiter tokens.
This was recently fixed in #246
by including Token::SemiColon to the list, but it felt wrong to have
to update this list, and to have a common list of delimiters for two
different contexts (CREATE TABLE with parens vs ALTER TABLE ADD COLUMN
without parens).
Also our current approach cannot handle multiple statements NOT
separated by a semicolon, as is common in MS SQL DDL. We don't
explicitly support it in `parse_statements`, but that's a use-case
like to keep in mind nevertheless.1 parent f57f314 commit 8106d25
2 files changed
+40
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1225 | 1225 | | |
1226 | 1226 | | |
1227 | 1227 | | |
1228 | | - | |
1229 | | - | |
1230 | | - | |
1231 | | - | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1232 | 1243 | | |
1233 | 1244 | | |
1234 | 1245 | | |
| |||
1238 | 1249 | | |
1239 | 1250 | | |
1240 | 1251 | | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
1250 | 1255 | | |
1251 | | - | |
| 1256 | + | |
1252 | 1257 | | |
1253 | | - | |
| 1258 | + | |
1254 | 1259 | | |
1255 | | - | |
| 1260 | + | |
1256 | 1261 | | |
1257 | | - | |
| 1262 | + | |
1258 | 1263 | | |
1259 | 1264 | | |
1260 | 1265 | | |
| |||
1273 | 1278 | | |
1274 | 1279 | | |
1275 | 1280 | | |
1276 | | - | |
| 1281 | + | |
1277 | 1282 | | |
1278 | 1283 | | |
1279 | 1284 | | |
1280 | 1285 | | |
1281 | | - | |
| 1286 | + | |
1282 | 1287 | | |
1283 | 1288 | | |
1284 | 1289 | | |
1285 | 1290 | | |
1286 | | - | |
| 1291 | + | |
1287 | 1292 | | |
1288 | 1293 | | |
1289 | | - | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
1290 | 1297 | | |
1291 | 1298 | | |
1292 | | - | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
1293 | 1302 | | |
1294 | | - | |
1295 | | - | |
1296 | | - | |
1297 | | - | |
| 1303 | + | |
| 1304 | + | |
1298 | 1305 | | |
1299 | 1306 | | |
1300 | 1307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1141 | 1141 | | |
1142 | 1142 | | |
1143 | 1143 | | |
1144 | | - | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
1145 | 1151 | | |
1146 | 1152 | | |
1147 | 1153 | | |
| |||
0 commit comments