What does HackerNews think of pg_jsonschema?

PostgreSQL extension providing JSON Schema validation

Language: Rust

> In other words, there is still a (lossy) translation layer, it just happens to be in the RDBMS rather than in-app.

It's not lossy if your application can guarantee a json <-> datatype roundtrip and the json is validated with jsonschema (generated by your application)

In Rust it's something like this

https://serde.rs/ to do the data type <-> json mapping

https://docs.rs/schemars/latest/schemars/ to generate jsonschema from your types

https://github.com/supabase/pg_jsonschema to validate jsonschema in your database (postgres). with this setup it's interesting (but not required) to also use https://docs.rs/jsonschema/latest/jsonschema/ to validate the schema in your application

Pretty exciting!

What about optionally validating some columns with jsonschema? Perhaps using https://github.com/supabase/pg_jsonschema - is using other postgres extensions supported in FerretDB? (if not, maybe it's feasible to incorporate the code of pg_jsonschema in FerretDB?)

totally agree

""Using composite types is mildly annoying since you must wrap the composite column in parenthesis to access the field"""

^ yeah that is frustrating

--

if you create domains over jsonb frequently, check out pg_jsonschema[1] as a way to express the constraints more concisely

[1] https://github.com/supabase/pg_jsonschema

Sounds dumb, but I want JSON field schema validation. I added a JSON column for flexible data, and although I'm happy with its flexibility, I kinda hope I can validate the JSON data structure. Recently I just found an extension [1] and will try soon.

[1] https://github.com/supabase/pg_jsonschema