Cloud Parts

Query builders

Let you write SQL through a typed API in your own language, checked by the compiler, and map results to typed rows without tracking objects afterwards.

How they work

A query builder models SQL itself rather than objects. In jOOQ you write select(...).from(AUTHOR).join(BOOK)... in Java, against classes generated from the live database schema, so a renamed column breaks the build instead of production. Drizzle does the same in TypeScript from tables declared in code (“If you know SQL, you know Drizzle”), Kysely is a type-safe TypeScript query builder inspired by Knex, and SQLAlchemy Core is the expression language underneath the SQLAlchemy ORM.

There is no session and no lazy loading: every query and every write is explicit, so what runs is what you wrote. Related data comes back through joins, or through nested collections built in one statement, such as jOOQ’s MULTISET or Drizzle’s relational queries, which always produce one SQL statement. Pick this kind when the team thinks in SQL and wants type safety without an object model to keep in sync.

Technologies

What all object-relational mapping have in common →

Sources

Improve this page on GitHub