Commit c815337
feat(postgresql): add bare_label_keyword support for column aliases without AS (#45)
Fix parsing of statements like `SELECT 1 name;` where `name` is used as a
column alias without the AS keyword.
PostgreSQL's keyword system has 5 categories, but our grammar only implemented 4:
- reserved_keyword
- unreserved_keyword
- col_name_keyword
- type_func_name_keyword
- bare_label_keyword (NEW - orthogonal to the above)
The bare_label_keyword category (455 keywords) determines which keywords can be
used as column labels without the AS keyword. Keywords marked as AS_LABEL (39)
require the AS keyword when used as aliases.
Changes:
- Updated keyword-generator to extract and generate bare_label_keyword rule
- Added bare_col_label rule to PostgreSQLParser.g4
- Updated target_alias to use bare_col_label instead of identifier
- Added regression test for bare column labels
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <[email protected]>1 parent 17b1619 commit c815337
File tree
10 files changed
+17180
-14037
lines changed- postgresql
- examples/regression
- keyword-generator
10 files changed
+17180
-14037
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4043 | 4043 | | |
4044 | 4044 | | |
4045 | 4045 | | |
4046 | | - | |
| 4046 | + | |
4047 | 4047 | | |
4048 | 4048 | | |
4049 | 4049 | | |
| |||
4182 | 4182 | | |
4183 | 4183 | | |
4184 | 4184 | | |
| 4185 | + | |
| 4186 | + | |
| 4187 | + | |
| 4188 | + | |
| 4189 | + | |
| 4190 | + | |
| 4191 | + | |
| 4192 | + | |
4185 | 4193 | | |
4186 | 4194 | | |
4187 | 4195 | | |
| |||
4197 | 4205 | | |
4198 | 4206 | | |
4199 | 4207 | | |
4200 | | - | |
4201 | | - | |
4202 | | - | |
| 4208 | + | |
| 4209 | + | |
| 4210 | + | |
4203 | 4211 | | |
4204 | 4212 | | |
4205 | 4213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | | - | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
| |||
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
63 | 74 | | |
64 | 75 | | |
65 | | - | |
| 76 | + | |
66 | 77 | | |
67 | 78 | | |
68 | 79 | | |
| |||
146 | 157 | | |
147 | 158 | | |
148 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
149 | 171 | | |
150 | 172 | | |
151 | 173 | | |
| |||
160 | 182 | | |
161 | 183 | | |
162 | 184 | | |
163 | | - | |
| 185 | + | |
164 | 186 | | |
165 | 187 | | |
166 | 188 | | |
| |||
261 | 283 | | |
262 | 284 | | |
263 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
264 | 306 | | |
265 | 307 | | |
266 | 308 | | |
| |||
0 commit comments