PG community had a similar patch, which got reverted from PG 15 on the last minute: <a href="https://www.depesz.com/2022/04/06/waiting-for-postgresql-15-json_table/" rel="nofollow">https://www.depesz.com/2022/04/06/waiting-for-postgresql-15-...</a>
I've found that this PL/pgSQL implementation also works well when you don't need maximum performance:<p><a href="https://github.com/gavinwahl/postgres-json-schema">https://github.com/gavinwahl/postgres-json-schema</a>
This is long overdue and elegantly done. Great work!<p>On a personal note, it's great to finally see Neon & Supabase playing with each other. Much more interesting to me than Hasura.
I've tried to use JSON Schema and the big gap I couldn't figure was how to handle polymorphism.<p>That is, if I have a case where object<p><pre><code> {
"Foo": {
"Type":"Fred"
"Bar":1
"Baz":2
"Quux":2
}
}
</code></pre>
and the object<p><pre><code> {
"Foo": {
"Type":"Waldo"
"Bar":1
"Corge":2
"Xyzzy":7
}
}
</code></pre>
are both valid, without just allowing any object members or allowing the union of their members.<p>I did a hack by multiplexing the types into a child-object, but that was ugly and clumsy.<p>In XSD or any statically-typed programming language I could handle this trivially using types and polymorphism, because "Fred" and "Waldo" would be different types.<p>But I can't figure out how to do that in Json Schema.
well written article and looks like a great extension. However, my only issue with JSON Schema is that it becomes unsupportable once your JSON objects get too big: to many keys or too many items in an array for example. If you are looking to find "where" the issue is in your JSON object, most schema validators don't provide enough guidance, they just say "something is wrong" as it appears this one does.
I can see some technical advantages to supporting JSON schema directly; but I suspect most people will be using this extension because SQL is really ugly and they don't want to use it to set up their schemas in pg proper.<p>It says a lot about how weak the SQL syntax is. An extension to replace CREATE TABLE with a JSON schema construct would be wildly popular.