TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Pg_jsonschema – JSON Schema Support for Postgres

219 点作者 awalias大约 2 年前

14 条评论

onderkalaci大约 2 年前
PG community had a similar patch, which got reverted from PG 15 on the last minute: <a href="https:&#x2F;&#x2F;www.depesz.com&#x2F;2022&#x2F;04&#x2F;06&#x2F;waiting-for-postgresql-15-json_table&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.depesz.com&#x2F;2022&#x2F;04&#x2F;06&#x2F;waiting-for-postgresql-15-...</a>
评论 #35259352 未加载
评论 #35274852 未加载
评论 #35267180 未加载
julian37大约 2 年前
I&#x27;ve found that this PL&#x2F;pgSQL implementation also works well when you don&#x27;t need maximum performance:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;gavinwahl&#x2F;postgres-json-schema">https:&#x2F;&#x2F;github.com&#x2F;gavinwahl&#x2F;postgres-json-schema</a>
boomskats大约 2 年前
This is long overdue and elegantly done. Great work!<p>On a personal note, it&#x27;s great to finally see Neon &amp; Supabase playing with each other. Much more interesting to me than Hasura.
评论 #35259312 未加载
评论 #35259053 未加载
Pxtl大约 2 年前
I&#x27;ve tried to use JSON Schema and the big gap I couldn&#x27;t figure was how to handle polymorphism.<p>That is, if I have a case where object<p><pre><code> { &quot;Foo&quot;: { &quot;Type&quot;:&quot;Fred&quot; &quot;Bar&quot;:1 &quot;Baz&quot;:2 &quot;Quux&quot;:2 } } </code></pre> and the object<p><pre><code> { &quot;Foo&quot;: { &quot;Type&quot;:&quot;Waldo&quot; &quot;Bar&quot;:1 &quot;Corge&quot;:2 &quot;Xyzzy&quot;: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 &quot;Fred&quot; and &quot;Waldo&quot; would be different types.<p>But I can&#x27;t figure out how to do that in Json Schema.
评论 #35262376 未加载
mehdix大约 2 年前
The article is also a joy to read. Well done.
hhthrowaway1230大约 2 年前
Ah yeah super nice always wanted schema support in progress love to see them hammering away on top of the solid foundation of postgres
Kydlaw大约 2 年前
&gt; 2022-08-19<p>Has anyone tried it? Any feedback on it?
评论 #35260240 未加载
korijn大约 2 年前
So how do you apply this in the real world when dealing with schema versions and database migrations?
评论 #35259751 未加载
评论 #35259557 未加载
anonu大约 2 年前
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 &quot;where&quot; the issue is in your JSON object, most schema validators don&#x27;t provide enough guidance, they just say &quot;something is wrong&quot; as it appears this one does.
marwis大约 2 年前
The detail error from example is pretty awful and missing any useful detail. Is it the limitation of the jsonschema library?
naedish大约 2 年前
This is interesting. Would be curious to see if this can replace pydantic for specific cases.
评论 #35259247 未加载
rapfaria大约 2 年前
Wouldn&#x27;t you wanna save the json even if the structure is incorrect?
评论 #35261889 未加载
raydiatian大约 2 年前
This looks rad.
roenxi大约 2 年前
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&#x27;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.