Commit e591425
COPY JSON: use trailing commas in FORCE_ARRAY output
Change COPY TO ... FORMAT JSON, FORCE_ARRAY output to place commas at
the end of each array element line, instead of at the beginning of the
next line.
Previously, output looked like this:
```
[
{"id":1}
,{"id":2}
]
```
This is valid JSON, but it is an unusual formatting style and can be
surprising to readers. Make it emit the more conventional form instead:
```
[
{"id":1},
{"id":2}
]
```
Implement this without buffering the whole result by adjusting how JSON
rows are terminated and how the separator is emitted between rows.
Update the regression test output accordingly.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Alex Guo <guo.alex.hengchen@gmail.com>
Discussion: https://postgr.es/m/DFAC4097-2559-4DED-B7D5-EB53B02E9DA3@gmail.com1 parent 127ce77 commit e591425
2 files changed
Lines changed: 36 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| |||
349 | 350 | | |
350 | 351 | | |
351 | 352 | | |
| 353 | + | |
| 354 | + | |
352 | 355 | | |
353 | 356 | | |
354 | 357 | | |
| |||
418 | 421 | | |
419 | 422 | | |
420 | 423 | | |
| 424 | + | |
421 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
422 | 429 | | |
423 | 430 | | |
424 | 431 | | |
| |||
447 | 454 | | |
448 | 455 | | |
449 | 456 | | |
450 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
451 | 461 | | |
452 | 462 | | |
453 | 463 | | |
| |||
659 | 669 | | |
660 | 670 | | |
661 | 671 | | |
662 | | - | |
663 | | - | |
| 672 | + | |
664 | 673 | | |
665 | | - | |
666 | | - | |
| 674 | + | |
| 675 | + | |
667 | 676 | | |
668 | 677 | | |
669 | 678 | | |
| |||
682 | 691 | | |
683 | 692 | | |
684 | 693 | | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
685 | 704 | | |
686 | 705 | | |
687 | 706 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
| 97 | + | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
| 102 | + | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
0 commit comments