BrazilJS

Share this post

Melhor suporte a JSON no PostgreSQL 14

www.braziljs.org

Melhor suporte a JSON no PostgreSQL 14

Agora, no PostgreSQL 14, o suporte JSON está ainda melhor e mais amigável do que antes.

BrazilJS
Jun 15, 2021
2
Share

O PostgreSQL já possui suporte a JSON há quase 10 anos,
No início, havia apenas uma validação do JSON e o armazenamento era em um campo de texto padrão.
Já no PostgreSQL 9.4 o suporte JSON melhorou com a introdução do tipo de dados JSONB.
Agora, no PostgreSQL 14, o suporte JSONB está ainda melhor e mais amigável do que antes.

Veja um exemplo de mudança de sintaxe:

--PostgreSQL 13
SELECT *
FROM shirts
WHERE details->'attributes'->>'color' = 'neon yellow'
AND details->'attributes'->>'size' = 'medium';
--PostgreSQL 14
SELECT *
FROM shirts
WHERE details['attributes']['color'] = '"neon yellow"'
AND details['attributes']['size'] = '"medium"'
view raw pg14.sql hosted with ❤ by GitHub

Saiba mais: https://blog.crunchydata.com/blog/better-json-in-postgres-with-postgresql-14

2
Share
Comments
Top
New
Community

No posts

Ready for more?

© 2023 BrazilJS
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing