jsonfmt

package
v1.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package jsonfmt holds the JSON formatter the compose dialects use in place of bun v1.3.0's, which mis-escapes the text \u0000 (https://github.com/uptrace/bun/issues/1472). It is internal so it can go when bun ships the fix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendJSON

func AppendJSON(b, jsonb []byte) []byte

AppendJSON appends jsonb, an encoding/json document, to b as a single-quoted SQL string literal, the way bun's schema.BaseDialect.AppendJSON does, with one correction: an escaped backslash pair (\\) is consumed as a pair, so its second half cannot start a \u0000 escape.

bun v1.3.0 stores the \u0000 escape, which no Postgres text can hold, as the literal text \u0000 by doubling its backslash. Reading one byte at a time it mistakes the second backslash of \\u0000, encoding/json's form of the text \u0000 itself, for the start of that escape and emits \\\u0000, which Postgres rejects for jsonb and misreads for json. Quotes are doubled, a raw NUL byte is dropped, and any other backslash is emitted alone so the byte after it is escaped by the loop, as in bun.

The Postgres and SQLite dialects of compose use it in place of bun's.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL