Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot serialize boolean values for JSON/JSONB columns #1003

Closed
darkgnotic opened this issue Dec 31, 2024 · 3 comments
Closed

Cannot serialize boolean values for JSON/JSONB columns #1003

darkgnotic opened this issue Dec 31, 2024 · 3 comments

Comments

@darkgnotic
Copy link

Most primitives are successfully serializable into JSON columns, but boolean appears to be the exception.

await db`CREATE TABLE foo(value JSON)`;

for (const value of ['string-value', 123, true]) {
  await db`INSERT INTO foo (value) VALUES (${value})`;
}

// Result: PostgresError: column "value" is of type json but expression is of type boolean

The string and number values are successfully serialized with the JSON type converter, but the boolean is not.

Is it possible that the inferType method is preventing the boolean value from being treated as a JSON value?

Unfortunately I don't understand the type handling code well enough to offer a solution.

Any help is much appreciated! 🙏

@porsager
Copy link
Owner

porsager commented Dec 31, 2024

Check out #392 😊

@tantaman
Copy link

Fixing the link -- #392 🙃

@porsager
Copy link
Owner

Heh.. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants