Skip to content

Commit 9af641b

Browse files
committed
Add enum representation notes
1 parent aae4e4e commit 9af641b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

AST_RESEARCH.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ These changes indicate incremental evolution in the ASTs, with PG16 introducing
7272
| `varnosyn` & `varattnosyn` | `varnullingrels` | Var | PG16 |
7373
| `aggtranstype` | `aggtransno` | Aggref | PG16 |
7474

75+
### Enum representation changes
76+
77+
Historically libpg_query exposed enum fields in the JSON output as **numeric**
78+
codes. Starting with the PG15 bindings this switched to returning the **string**
79+
name of each enum value. The TypeScript type definitions reflect string literal
80+
unions across all versions, but the underlying JSON changed in PG15.
81+
82+
| Version | Enum format |
83+
|---------|-------------|
84+
| 13–14 | integers |
85+
| 15–17 | strings |
86+
7587

7688
## Version similarity
7789

AST_TRANSLATION.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ Trade-offs:
3838
- Performance hit due to serializing and parsing again
3939
- Potential loss of fidelity if certain node properties are not round-trippable
4040

41+
### Handling enums
42+
43+
Older versions of `libpg_query` (PG13 and PG14) emitted numeric codes for enum
44+
fields. From PG15 onward the JSON output uses the enum **name** as a string.
45+
Translation code must therefore convert numeric enums to their string
46+
equivalents when upgrading from PG13/14. When moving between PG15–17 the
47+
representations already match.
48+
4149
## Translation step ordering
4250

4351
### Sequential upgrades

0 commit comments

Comments
 (0)