discriminated union columns in Postgres via pg_jsonschema 🤌
29K followers
17,511 views
21 Comments
Comments from the original post on X (Twitter)

@colinhacks
we did it joe
9 likes

@colinhacks
more JSON Schema + Reylo examples
10 likes

@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
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

@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

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

@axadrn
pg_jsonschema is one of those extensions i keep forgetting exists
2 likes

@colinhacks
yeah @supabase cooked
2 likes

@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

@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

@bcomnes
Sweet
1 like

@NFS__21
tsrs support ?

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

@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

@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

@felixizraitel
very nice

@0xileri
🔥

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

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

@jingleberry69
I will name my first born son Colin.
