Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

type inference from .sql files has been achieved internally ORMs are toast

382,980 Aufrufe • vor 2 Tagen •via X (Twitter)

48 Kommentare

Profilbild von colinhacks
colinhacksvor 2 Tagen

this is still beta but you can play with it here 👉

Profilbild von Drizzle ORM
Drizzle ORMvor 2 Tagen

Wow, nice Is that fundamentally different from what prisma’ve done?

Profilbild von colinhacks
colinhacksvor 2 Tagen

I have a hundred issues with TypedSQL but tl;dr I think content mappers in TS 7.1 change the calculus for something like this 👍

Profilbild von Igal Klebanov
Igal Klebanovvor 2 Tagen

very cool use of the new ts stuff! the ecosystem had these author-raw-get-something-typechecked things for a while now. some with codegen, some through ide extensions - so removing the need for something extra in process or dependencies is dope.

Profilbild von colinhacks
colinhacksvor 2 Tagen

game changer for sure! I'm happy for an excuse to start my next database tooling era ✨

Profilbild von Kazi Ahmed ⚡
Kazi Ahmed ⚡vor 2 Tagen

Maannnnn how. How can it know the union? That blew me away. I'm sold. I'm all for type safety, so much so that I have made Tanstack Router like back-end API router that knows layout params or auth state with type safety for that layout branch.

Profilbild von colinhacks
colinhacksvor 2 Tagen

a LOT of work went into inference engine. check out the Inference docs here for a bunch of examples, you'll dig it 👇

Profilbild von Kazi Ahmed ⚡
Kazi Ahmed ⚡vor 2 Tagen

Sorry it suddenly hit me. Does the mappers also work as a module loader or transformer during build or bundle? Inferring types is one thing but wrapping the contents of the SQL file with custom adapter is different. Looks like ts prescribing to use bundlers like vite?

Profilbild von colinhacks
colinhacksvor 2 Tagen

good question, you need to configure Reylo in tsconfig.json and in your bundler/runtime config to have agreement. it's similar to using tsconfig "paths" Reylo is one package containing lots of plugins lol

Profilbild von Kazi Ahmed ⚡
Kazi Ahmed ⚡vor 2 Tagen

Thanks. That makes perfect sense. I was reading the Reylo codebase and found the plugins. There's a lot of goodies in the codebase.

Profilbild von Matija Sosic
Matija Sosicvor 2 Tagen

I was wondering how/why to use Reylo instead of a "regular" ORM like @prisma or @DrizzleORM, so I put together a quick explainer. TL;DR: - This is possible due to a new mechanism in TS 7.1 - It's a way to get type-safe SQL without codegen - It actually talks to your db, at compile time, to check the types

Profilbild von Chris Griffing
Chris Griffingvor 2 Tagen

Its not about the lack of ORMs at the end, it's about the ORMs we made along the way.

Profilbild von Francisco Hermida PRO
Francisco Hermida PROvor 2 Tagen

this for sqlfu @mmkalmmkal ? would you still recommend it?

Profilbild von Matsu
Matsuvor 2 Tagen

How does this differ from something like Kysely? By allowing you to import sql files instead of using a tagged template literal?

Profilbild von Aditya Deshlahre
Aditya Deshlahrevor 2 Tagen

Wow, it works out of the box nice

Profilbild von Lachy
Lachyvor 2 Tagen

if types come from the .sql file itself, how does it resolve a column's type for a join across two tables? does it read the live database schema at build time, or a schema file checked into the repo?

Profilbild von colinhacks
colinhacksvor 2 Tagen

good question, Reylo's inference engine sends the query to your database, extracts out the type descriptors from the prepared query, and cross-references against catalog (Postgres) or information_tables (other dialects) so the type information always comes from the database itself 👍

Profilbild von Lubos @heyapi.dev
Lubos @heyapi.devvor 2 Tagen

I want some of what you’re on

Profilbild von Kizuno18
Kizuno18vor 2 Tagen

skipping the codegen step and having direct compiler inference from raw .sql is huge. how does the parser handle complex jsonb projections or cte unions?

Profilbild von Rajat
Rajatvor 2 Tagen

Damn 🔥 Is it possible to write SQL inside .ts files and get the same type inference?

Profilbild von colinhacks
colinhacksvor 2 Tagen

unfortunately not, I heard @atcb may have some early plans cooking for that but I actually prefer for stuff like this to happen at an import boundary. Reylo is implemented as a content mapper (basically a plugin for TypeScript)

Profilbild von Rajat
Rajatvor 2 Tagen

@atcb can you make a plugin for jsonc too? its been a while since people asking for a support in typescript repo

Profilbild von colinhacks
colinhacksvor 2 Tagen

@atcb that's supported in Motherload!

Profilbild von ucixrn
ucixrnvor 2 Tagen

Looks cool

Profilbild von freddie
freddievor 2 Tagen

query builders* ORMs are fine

Profilbild von Jaga santagostino
Jaga santagostinovor 2 Tagen

bittersweet to have this after agents 🥲

Profilbild von klitty
klittyvor 2 Tagen

please i cant keep up anymore

Profilbild von Wessel E
Wessel Evor 2 Tagen

Give us six months and we'll put an ORM back on top of those.sql files.

Profilbild von Rapid
Rapidvor 2 Tagen

ORM in 2026 😅 what

Profilbild von TheOneHong阿康
TheOneHong阿康vor 2 Tagen

if type inference can be done with embedded sql statement, will be goated

Profilbild von Europäische Aktion 🇪🇺 🇩🇪
Europäische Aktion 🇪🇺 🇩🇪vor 2 Tagen

Is it compatible with Bun?

Profilbild von diip3sh
diip3shvor 2 Tagen

does the inference track a left join becoming effectively inner when a where clause rules out nulls on the joined table?

Profilbild von el jesu 😎
el jesu 😎vor 2 Tagen

Hi! question from a humble java Dev watching your video made me realize that you'd add one SQL file for every query wou use is it something standard in typescript/JavaScript backbends? it seems to me that's only appropriate for micro micro services

Profilbild von Stephen
Stephenvor 2 Tagen

This is similar to what SQLC does in Golang...

Profilbild von Łukasz Jagodziński
Łukasz Jagodzińskivor 2 Tagen

ORMs are not toasted as you can’t build type safe dynamic queries this way. I built an SQL code generator in the past and it was the biggest issue with that kind of solution. I guess you could have more complex logic in SQL but most people will prefer building their queries with query builders.

Profilbild von Hussein Kizz ★
Hussein Kizz ★vor 2 Tagen

Are we to throw away our ORMs now?

Profilbild von Matija Sosic
Matija Sosicvor 2 Tagen

Why is this better than using an ORM like Prisma or Drizzle?

Profilbild von Chud
Chudvor 2 Tagen

this is actually crazy, great things coming typescript’s way

Profilbild von David Klingenberg
David Klingenbergvor 2 Tagen

Wow, that's pretty cool. It reminds me Type Providers in F# :)

Profilbild von zlumer.eth
zlumer.ethvor 2 Tagen

amazing! does it use pgtyped or how it compares?

Profilbild von smallshen
smallshenvor 2 Tagen

What about use prql?

Profilbild von Alberto Díaz
Alberto Díazvor 2 Tagen

What do ORMs provide over this? I guess that some people prefer to write queries using ORMs rather than SQL?

Profilbild von colinhacks
colinhacksvor 2 Tagen

declarative schema & migrations are nice! Reylo doesn't do that (probably never will) but with content mappers enabling direct .sql imports from TypeScript files, I don't really see why anyone would use an ORM over Reylo for actually writing queries

Profilbild von Alberto Díaz
Alberto Díazvor 2 Tagen

Any chance that we get type inference from inline queries? Or must they be a separate SQL file? I am eager to try Reylo, but I am wondering if I can truly apply it to a project where every query is inline (within TS files)

Profilbild von colinhacks
colinhacksvor 2 Tagen

it's not possible with content mappers. you could probably use Reylo's engine and integrate it into some kind of build step, but I'm pretty allergic to that kind of thing...lots of thorny edge cases when it comes to static analysis like this

Profilbild von Alberto Díaz
Alberto Díazvor 2 Tagen

Thanks! I would have to extract every single SQL query into a companion SQL file. Tbh, I may give it a try. I was planning to move everything to kysely or drizzle, but... Reylo looks kinda neat :D

Profilbild von Sacha
Sachavor 2 Tagen

This 97 year old diner still serves their Coke the old-fashioned way.

Profilbild von Jon Åslund
Jon Åslundvor 2 Tagen

Why does it infer return type | null after you add the email where clause?

Ähnliche Videos