Skip navigation
discriminated union columns in Postgres via pg_jsonschema 🤌
0:00 / 0:22

discriminated union columns in Postgres via pg_jsonschema 🤌

317 likesDownloadOriginal post

17,511 views

discriminated union columns in Postgres via pg_jsonschema 🤌 full inference via Reylo 🤌🤌🤌

21 Comments

Comments from the original post on X (Twitter)

  • colinhacks's profile picture

    @colinhacks

    we did it joe

    9 likes

  • colinhacks's profile picture

    @colinhacks

    more JSON Schema + Reylo examples

    10 likes

  • Emil Nordgård's profile picture

    @Meliketoast21

    Always liked EdgeQL. How much of Reylo draws your work in Gel/edgedb? Lately I just want relational structs without materializing anything, basically just trying to have a relational for loop :P

    2 likes

  • colinhacks's profile picture

    @colinhacks

    Reylo is very much my attempt to finish what EdgeDB started someone ironic that the new calculus around ergonomics has steered me towards SQL-maximalism but the goals are the same! in fact the JSON agg approaches I document on the homepage are exactly what the EdgeDB compiler used to produce internally for nested fetches in EdgeQL 😛

    1 like

  • Emil Nordgård's profile picture

    @Meliketoast21

    for user in User[.friends[.cool], .name != 'Joe'] { print( } Already generating SQL for stuff like this via column streaming + AST, but it's painful without LATERAL in maria lol. Might make a language for it. Fun compiler potential :P

  • Emil Nordgård's profile picture

    @Meliketoast21

    Something fun about emission boundaries being selection. this notation is really fun.

  • Axel Adrian's profile picture

    @axadrn

    pg_jsonschema is one of those extensions i keep forgetting exists

    2 likes

  • colinhacks's profile picture

    @colinhacks

    yeah @supabase cooked

    2 likes

  • Im's profile picture

    @ImaammDev

    How do you handle schema changes for rows already written? A CHECK constraint re validates on every UPDATE, so tightening the schema means old rows fail on unrelated edits. ADD ... NOT VALID + backfill first saves you there.

    2 likes

  • Chenxin Yan's profile picture

    @chenxinyan

    This is saving my ass. I can’t remember how many times I had to rawdog the typing for this kind of stuff just cuz the type can’t be inferred. It’s so annoying

    1 like

  • Bret Comnes's profile picture

    @bcomnes

    Sweet

    1 like

  • Nafees Nazik's profile picture

    @NFS__21

    tsrs support ?

  • colinhacks's profile picture

    @colinhacks

    ask an agent it's on them to support the Content Mapper API. they probably already do, pretty sure they track main 👍

  • Ilya Berezhniak's profile picture

    @iberezh_

    nice. have you measured the check on bulk inserts? it runs the schema per row, so i'm curious how much it adds on a 1M row COPY compared to a plain jsonb column

  • ElHussein Abdelwahab's profile picture

    @husseinraoouf

    having postgres reject the bad row is what i'd want most here. a schema in app code only guards writes that go through the app, and more and more don't: backfill scripts, one-off sql, an agent poking at the db to fix something. typed reads on top is a nice bonus

  • Felix Izraitel's profile picture

    @felixizraitel

    very nice

  • ileri 𖣂's profile picture

    @0xileri

    🔥

  • Anton wester's profile picture

    @Antonwester5

    It seems like reylo is slower than Drizzle, any changes coming that will change that?

  • Dominik Zogg's profile picture

    @dominikzogg

    I ask myself why people hate MongoDB that much to implement a worse version in top of postgres (my favorite relational db).

  • James Ripley's profile picture

    @jingleberry69

    I will name my first born son Colin.